mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Adapt CC Mode for C++11 uniform initialization.
For fontification, introduce a new "context", 'non-decl, to be used for
brace
lists; also a new value for the property 'c-type, called 'c-not-decl.
* lisp/progmodes/cc-engine.el (c-back-over-compound-identifier): Check that
an ostensible symbol we're going to move over isn't a keyword.
(c-forward-decl-or-cast-1): CASE 1: Where we have two consecutive identifiers
(hence a declaration), and an unmatched open paren, perform
c-fdoc-shift-type-backwards to recognize the partial construct correctly.
Whilst checking a type decl expression, check for and handle C++11's "copy
initialization", where we have <type>(<constant>). Recognize
<id><id>(... (where the paren is unclosed) as a declaration.
(c-looking-at-or-maybe-in-bracelist): New function, extracted from
c-inside-bracelist-p. Recognize as bracelists "{"s which are preceded by
valid tokens other than "=". Recognize a bracelist when preceded by a
template declaration.
(c-inside-bracelist-p): Call c-looking-at-or-maybe-in-bracelist in place of
much inline code.
(c-looking-at-inexpr-block): Amend so that it won't wrongly recognise an
initialization starting "({" as an in-expression block, by checking for
semicolons, as opposed to commas, separating elements inside it.
(c-guess-continued-construct): (CASE B-2): Recognize a brace-list-open by
calling c-looking-at-or-maybe-in-bracelist rather than checking for a
preceding "=". (CASE B-5): New code to recognize new construct "return {
...}".
(c-guess-basic-syntax): (CASE 5A.3): Additionally recognize a "{" preceded by
"return", or "{" preceded by <type><identifier> as a bracelist.
* lisp/progmodes/cc-fonts.el (c-font-lock-declarations): Recognize brace
lists, giving them `context' 'non-decl. Pass over elements of one by regexp
search for "," rather than calling c-forward-decl-or-cast-1.
* lisp/progmodes/cc-langs.el (c-return-kwds, c-return-key): New lang
constants/variables to recognize "return".
(c-pre-id-bracelist-key): New lang constant/variable to recognize tokens
which, when preceding an identifier followed by a brace, signify the brace as
a bracelist.
* lisp/progmodes/cc-mode.el (c-fl-decl-start): When searching outwards for
the start of a "local" declaration, move out from an enclosing brace when
that is the start of a brace list.
This commit is contained in:
parent
1f7302563a
commit
578d9aaf82
4 changed files with 406 additions and 239 deletions
|
|
@ -1772,6 +1772,16 @@ the appropriate place for that."
|
|||
"array" "float" "function" "int" "mapping" "mixed" "multiset"
|
||||
"object" "program" "string" "this_program" "void"))
|
||||
|
||||
(c-lang-defconst c-return-kwds
|
||||
"Keywords which return a value to the calling function."
|
||||
t '("return")
|
||||
idl nil)
|
||||
|
||||
(c-lang-defconst c-return-key
|
||||
;; Adorned regexp matching `c-return-kwds'.
|
||||
t (c-make-keywords-re t (c-lang-const c-return-kwds)))
|
||||
(c-lang-defvar c-return-key (c-lang-const c-return-key))
|
||||
|
||||
(c-lang-defconst c-primitive-type-key
|
||||
;; An adorned regexp that matches `c-primitive-type-kwds'.
|
||||
t (c-make-keywords-re t (c-lang-const c-primitive-type-kwds)))
|
||||
|
|
@ -3150,6 +3160,13 @@ list."
|
|||
c t)
|
||||
(c-lang-defvar c-recognize-knr-p (c-lang-const c-recognize-knr-p))
|
||||
|
||||
(c-lang-defconst c-pre-id-bracelist-key
|
||||
"A regexp matching tokens which, preceding an identifier, signify a bracelist.
|
||||
"
|
||||
t "\\<\\>"
|
||||
c++ "new\\([^[:alnum:]_$]\\|$\\)\\|&&?\\(\\S.\\|$\\)")
|
||||
(c-lang-defvar c-pre-id-bracelist-key (c-lang-const c-pre-id-bracelist-key))
|
||||
|
||||
(c-lang-defconst c-recognize-typeless-decls
|
||||
"Non-nil means function declarations without return type should be
|
||||
recognized. That can introduce an ambiguity with parenthesized macro
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue