This fixes bug #4192.
* etc/NEWS: Add a new entry.
* lisp/progmodes/cc-defs.el (c-font-lock-flush): New macro.
* lisp/progmodes/cc-cmds.el (c-toggle-comment-style): On toggling the comment
style, invoke c-font-lock-flush when c-mark-wrong-style-of-comment is non-nil,
to cause that marking to be done instead on the other style of comment.
* lisp/progmodes/cc-fonts.el (c-maybe-font-lock-wrong-style-comments): New
function.
(c-cpp-matchers): Call c-maybe-font-lock-wrong-style-comments when
appropriate.
* lisp/progmodes/cc-vars.el (c-mark-wrong-style-of-comment): New customizable
option.
* doc/misc/cc-mode.texi (top level, Indentation Commands, Guessing the Style,
Custom Macros): For some opening quote marks, correct '' to ``.
(Minor Modes): Add an xref to the new page "Wrong Comment Style" in a
footnote.
(Wrong Comment Style): New page.
This fixes bug #10149.
* lisp/progmodes/cc-fonts.el (c-font-lock-single-decl) Limit the search by
c-go-up-list-backwards to 500 non-literal characters.
Also fix infinite loops by correcting two regexps.
* lisp/progmodes/cc-langs.el (c-last-c-comment-end-on-line-re)
(c-last-open-c-comment-start-on-line-re): Correct the regexp fragments
"\\*+[^/]" to "\\*+\\([^*/]\\|$\\)".
* lisp/progmodes/cc-fonts.el (gtkdoc-font-lock-keywords): Disallow /**/ for
doc comment fontification.
Also amend a pertinent regular expression. This fixes bug #11865.
* lisp/progmodes/cc-vars.el (c-doc-comment-style): Insert an entry for
c++-mode, namely gtkdoc.
* lisp/progmodes/cc-fonts.el (gtkdoc-font-lock-keywords): Amend the regexp
recognizing the introductory "/**" to allow subsequent characters on that
line.
This is because these variables are needed at runtime even when cc-fonts.el
hasn't been loaded, as in XEmacs when font locking hasn't been enabled.
* lisp/progmodes/cc-fonts.el (c-doc-line-join-re)
(c-doc-bright-comment-start-re, c-doc-line-join-end-ch): Move definitions to
cc-mode.el.
* lisp/progmodes/cc-engine.el (c-back-over-member-initializers): call
c-parse-state outside of the narrowing operation.
* lisp/progmodes/cc-fonts.el (c-get-fontification-context)
(c-font-lock-cut-off-declarators): Replace calls to c-determine-limit with
crude position calculations for speed.
* lisp/progmodes/cc-engine.el (c-end-of-macro): Check for being in a
degenerate zero length "macro", when setting the macro cache.
(c-determine-+ve-limit): Add in a missing goto-char form for when start-pos is
non-nil.
(c-back-over-member-initializers): Add a search limit parameter.
* lisp/progmodes/cc-fonts.el (c-get-fontification-context): Add a search limit
to c-go-up-list-backward.
(c-font-lock-cut-off-declarators): Add a search limit to
c-back-over-member-initializers.
* lisp/progmodes/cc-mode.el (c-before-change-check-unbalanced-strings): Don't
set c-new-END to the end of logical line (which might be a long macro).
(c-after-change-mark-abnormal-strings): Calculate end-hwm in place of the
setting of c-new-END (above). Use this as a search limit rather than
c-new-END.
(Intermediate commit)
* lisp/progmodes/cc-engine.el, lisp/progmodes/cc-fonts.el
* lisp/progmodes/cc-mode.el : Rename:
c-state-semi-nonlit-pos-cache -> c-lit-pos-cache,
c-state-semi-nonlit-pos-cache-limit -> c-lit-pos-cache-limit,
c-state-semi-nonlit-near-cache -> c-semi-lit-near-cache,
c-truncate-semi-nonlit-pos-cache -> c-truncate-lit-pos-cache,
c-state-semi-trim-near-cache -> c-semi-trim-near-cache,
c-state-semi-get-near-cache-entry -> c-semi-get-near-cache-entry,
c-state-semi-put-near-cache-entry -> c-semi-put-near-cache-entry,
c-state-semi-pp-to-literal -> c-semi-pp-to-literal,
c-state-full-pp-to-literal -> c-full-pp-to-literal,
c-state-semi-trim-cache -> c-trim-lit-pos-cache.
* lisp/progmodes/cc-engine.el (c-semi-near-cache-limit): New variable.
(c-truncate-lit-pos-cache): This now truncates the cache variables for all
three lit- sub-caches.
(c-semi-put-near-cache-entry): Increase c-semi-near-cache-limit to the
position of the new entry.
(c-full-near-cache-limit, c-full-lit-near-cache): New variables.
(c-full-trim-near-cache, c-full-get-near-cache-entry)
(c-full-put-near-cache-entry): New functions.
(c-full-pp-to-literal): Amend to use the new functions, and to optimize the
use of the available caches, similarly to c-semi-pp-to-literal.
* /lisp/progmodes/cc-fonts.el (c-font-lock-enum-body)
(autodoc-font-lock-line-markup): As part of the `while' condition, check that
the previous iteration of the loop hasn't moved point past `limit', thus
obviating "wrong side of point" errors in re-search-forward, etc.
E.g., on typing the closing delimiter of a string continued onto a second
line, the opening delimiter retained its font-lock-warning-face.
* lisp/progmodes/cc-defs.el (c-c++-raw-string-opener-re)
(c-c++-raw-string-opener-1-re): New constants.
(c-sub-at-c++-raw-string-opener, c-at-c++-raw-string-opener): New macros.
* lisp/progmodes/cc-engine.el (c-raw-string-pos)
(c-depropertize-raw-strings-in-region, c-after-change-unmark-raw-strings):
Replace uses of open-coded raw string regexps by the new constants and macros
in cc-defs.el.
* lisp/progmodes/cc-fonts.el (c-font-lock-raw-strings): Ditto
* lisp/progmodes/cc-mode.el (c-before-change-check-unbalanced-strings): Set
c-new-BEG to the beginning of the string when we encounter its closing ".
When not in a raw string, but in a string, clear syntax-table properties from
its delimiters and set c-new-BEG/END to its limits.
(c-after-change-mark-abnormal-strings): When applying syntax-table properties
to string delimiters, also set c-new-BEG/END to ensure subsequent
fontification.
* lisp/progmodes/cc-fonts.el (c-font-lock-complex-decl-prepare)
(c-font-lock-objc-methods) (c-font-lock-declarations, c-font-lock-enum-tail)
(c-font-lock-cut-off-declarators, c-font-lock-enclosing-decls): If the chunk
been fontified consists entirely of comments and strings, don't attempt to
perform the function's action.
* lisp/progmodes/cc-mode.el (c-before-change-check-unbalanced-strings): Don't
expand (c-new-BEG c-new-END) unnecessarily to the entire raw string being
fontified.
(c-fl-decl-start, c-fl-decl-end): When in a (raw or otherwise) string, don't
return a position outside of the string (which used to cause unneeded
fontification).
* lisp/progmodes/cc-engine.el (c-forward-sws, c-backward-sws): Recognize
matches of c-doc-line-join-re as syntactic whitespace.
(c-find-decl-prefix-search): Recognize and move over matches of
c-doc-line-join-re as whitespace.
(c-find-decl-spots): Before moving backward a char, check (bobp). Before
moving forward over a comment, check it isn't possibly a "bright" comment.
* lisp/progmodes/cc-fonts.el (c-get-doc-comment-style): New function,
extracted from c-compose-keywords-list.
(c-compose-keywords-list): Call the above new function.
(pike-font-lock-keywords, pike-font-lock-keywords-2)
(pike-font-lock-keywords-3): Call c-set-doc-comment-res.
(c-doc-line-join-re, c-doc-bright-comment-start-re, c-doc-line-join-end-ch):
New variables.
(c-set-doc-comment-re-element, c-set-doc-comment-char-list): New macros.
(c-set-doc-comment-res): New function.
(c-font-lock-doc-comments): For consistency and repeatability, in a sequence
of C++ style doc comments, don't fontify the region between BOL and the
comment marker.
(autodoc-line-join-re, autodoc-bright-comment-start-re)
(autodoc-line-join-end-ch): New variables.
* lisp/progmodes/cc-mode.el (c-doc-fl-decl-start, c-doc-fl-decl-end): New
functions.
(c-change-expand-fl-region, c-context-expand-fl-region): Call the above two
new functions for extra possibilities for the start and end of a construct.
* doc/misc/cc-mode.texi (Doc Comments): Add a sentence drawing attention to
the possibility of fontifying constructs within a doc comment.
Integrate the handling of raw string and ordinary string fontification.
* lisp/progmodes/cc-defs.el (c-font-lock-flush)
(c-search-forward-char-property-without-value-on-char): new macros.
(c-point): In the 'eoll arm, check for eobp.
(c-search-forward-char-property-with-value-on-char): Handle the &optional
limit argument being nil.
(c-clear-char-property-with-value-on-char-function)
(c-clear-char-property-with-value-on-char): Return the position of the first
cleared property.
* lisp/progmodes/cc-engine.el (c-find-decl-prefix-search): Don't spuriously
recognize the change of face at a ) as the start of a string (a
"pseudo match").
(c-old-beg-rs c-old-end-rs): New variables.
(c-raw-string-pos): Analyze raw string delimiters more carefully.
(c-raw-string-in-end-delim): New function.
(c-depropertize-raw-string): Largely rewritten.
(c-before-change-check-raw-strings): New functionality: only remove the
syntax-table text properties from raw strings whose delimiters are about to
change.
(c-propertize-raw-string-id): New function.
(c-after-change-re-mark-raw-strings): Remove, incorporating functionality into
other functions.
(c-propertize-raw-string-opener): Largely rewritten.
(c-after-change-re-mark-raw-strings): Removed.
(c-after-change-unmark-raw-strings, c-after-change-unmark-raw-strings): New
functions.
* lisp/progmodes/cc-fonts.el (c-font-lock-raw-strings): Largely rewritten.
* lisp/progmodes/cc-langs.el (c-before-font-lock-functions): Replace
c-after-change-re-mark-unbalanced-strings by
c-after-change-mark-abnormal-strings in the t, c+objc, c++ and java sections.
Add c-after-change-unmark-raw-strings and remove
c-after-change-re-mark-raw-strings from the c++ section.
* lisp/progmodes/cc-mode.el (c-old-BEG c-old-END): Remove.
(c-old-END-literality): New variable.
(c-depropertize-CPP): Remove syntax-table properties from raw strings within
macros.
(c-before-change-check-unbalanced-strings): Call
c-truncate-semi-nonlit-pos-cache to preserve the integrity of the cache.
(c-before-change-check-unbalanced-strings): Call
c-truncate-semi-nonlit-pos-cache, largely rewritten.
(c-after-change-re-mark-unbalanced-strings): Renamed to
c-after-change-mark-abnormal-strings. Call c-maybe-re-mark-raw-string.
while preserving the indentation of nested C++ uniform initialization.
* lisp/progmodes/cc-align.el (c-lineup-2nd-brace-entry-in-arglist)
(c-lineup-class-decl-init-+, c-lineup-class-decl-init-after-brace): New
indentation functions.
* lisp/progmodes/cc-engine.el (c-forward-class-decl): New function.
(c-do-declarators): New function, partially extracted from
c-font-lock-declarators, which now calls the new function.
(c-inside-bracelist-p): Amend the introductory comment.
(c-add-stmt-syntax): Add code to prevent the spurious recognition of a
'defun-block-intro when a brace pair is used as an initializer.
(c-evaluate-offset): No longer ignore vectors of length >= 2.
(c-calc-offset): Refactor clumsily nested `if'/`or' into a cond form.
* lisp/progmodes/cc-fonts.el (c-font-lock-declarators): Replace the bulk of
this function by a call to the new c-forward-class-decl.
* lisp/progmodes/cc-langs.el (c-type-decl-prefix-key): Recognize "~" as a
type decl operator.
* lisp/progmodes/cc-mode.el (c-fl-decl-start): While searching backward for a
"}" at an EOD, deal with actually finding the end of a brace list.
* doc/misc/cc-mode.texi (List Line-Up): document
c-lineup-2nd-brace-entry-in-arglist, c-lineup-class-decl-init-+, and
c-lineup-class-decl-init-after-brace.
* lisp/progmodes/cc-styles.el (c-style-alist): In styles "gnu", "bsd",
"stroustrup", "python", and "java", change the offset for brace-list-intro
from the default value or c-lineup-arglist-intro-after-paren to a list
beginning with the symbol first, followed by two of the new alignment
functions, followed by +.
* lisp/progmodes/cc-vars.el (c-offset-alist): Change the default value of
brace-list-entry from c-lineup-under-anchor back to 0.
This fixes bug #33784.
* lisp/progmodes/cc-fonts.el (c-get-fontification-context): While moving back
over enclosing parentheses, check that c-backward-token-2 actually moves.
* lisp/progmodes/cc-fonts.el (c-get-fontification-context): recognize
arithmetic operator followed by several open parentheses, not just one, as not
being an argument list.
* lisp/progmodes/cc-cmds.el, lisp/progmodes/cc-defs.el
lisp/progmodes/cc-engine.el, lisp/progmodes/cc-fonts.el
lisp/progmodes/cc-langs.el: Add lots of edebug specs.
* lisp/progmodes/cc-engine.el (c-state-maybe-marker): Tidy up so as to
evaluate an argument only once at runtime.
String delimiters, including escaped new lines, of correctly terminated
strings are left in font-lock-string-face. All others get
font-lock-warning-face. The latter get syntax-table text properties on the
opening string delim and the "terminating EOL".
Correct two miscellaneous bugs: the handling of text properties on Java Mode's
generic delimiters; the handling of c-just-done-before-change.
* lisp/progmodes/cc-defs.el (c-point): New position 'eoll "end of logical line".
(c-characterp): New macro.
* lisp/progmodes/cc-fonts.el (c-font-lock-invalid-string): Removed.
(c-basic-matchers-before): Use a simple matcher in place of the form around
c-font-lock-invalid-string.
* lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Add
c-before-change-check-unbalanced-strings to the value for all modes except AWK
Mode. Also add c-before-change-check-<>-operators to Java Mode, correcting an
error in that mode's handling of generic delimiters.
(c-before-font-lock-functions): Add c-after-change-re-mark-unbalanced-strings
to the value for all modes except AWK Mode.
(c-single-quotes-quote-strings, c-string-delims): New lang variables for
future enhancements.
(c-string-innards-re-alist): New lang variable.
* lisp/progmodes/cc-mode.el (c-just-done-before-change): Do not set this
variable when a change is the alteration of text properties.
(c-basic-common-init): Set parse-sexp-lookup-properties (and the XEmacs
equivalent) also for Pike Mode.
(c-neutralize-CPP-line): No longer neutralize unbalanced quotes here.
(c-unescaped-nls-in-string-p, c-multiline-string-start-is-being-detached)
(c-pps-to-string-delim, c-before-change-check-unbalanced-strings)
(c-after-change-re-mark-unbalanced-strings): New functions.
(c-after-change): Fix a bug with the handling of c-just-done-before-change.
* lisp/progmodes/cc-engine.el (c-inside-bracelist-p): Return a bufpos rather
than t for the enum case.
(c-add-stmt-syntax, c-guess-continued-construct): Replace
c-looking-at-or-maybe-in-bracelist by c-inside-bracelist-p, since the former
does not recognize enum brace lists, but the latter does.
* lisp/progmodes/cc-fonts.el (c-get-fontification-context): Replace
c-looking-at-or-maybe-in-bracelist by c-inside-bracelist-p.
* lisp/progmodes/cc-fonts.el (c-font-lock-doc-comments): Take into account
the possibility of font-lock-comment-delimiter-face. Test rigorously for
"/**" (etc.) being itself inside a literal, rather than just depending on the
face of the previous character.
Also recognize and handle function names introduced by "extern" inside a
function.
* lisp/progmodes/cc-engine.el (c-forward-decl-or-cast-1): Add a new element to
the result list which is t when our declaration is, or is to be treated as,
being at top level.
* lisp/progmodes/cc-fonts.el (c-get-fontification-context): Detect being
inside a C++ uniform initialization and return (not-decl nil) for this case.
(c-font-lock-declarations): Use the new element 4 of the result of
c-forward-decl-or-cast-1.
* lisp/progmodes/cc-langs.el (c-make-top-level-kwds, c-make-top-level-key):
New lang consts/vars.
This fixes (a follow-up to) bug #28850.
A internal generated form for scanning text to fontify had a LIMIT parameter.
It also locally bound LIMIT to a value possibly beyond the original LIMIT,
allowing point to move beyond the original LIMIT, and to create the wrong side
error. Fix it by checking point is not beyond LIMIT in the outer context
before using it.
* lisp/progmodes/cc-fonts.el (c-make-font-lock-search-form): Add a new
parameter CHECK-POINT which, when non-nil, directs the function to generate a
check on point.
(c-make-font-lock-context-search-function): Invoke the above function with new
argument value t.
The cause was a scanning over a bracket pair taking us beyond the supplied
LIMIT parameter in c-forward-declarator.
* lisp/progmodes/cc-engine.el (c-forward-declarator): Add three checks (<
(point) limit) whilst dealing with tokens after the declared identifier.
* lisp/progmodes/cc-fonts.el (c-font-lock-declarators): Don't supply a LIMIT
argument to `c-forward-declarator' (twice), since we want to fontify up till
the end of a declarator, not an arbitrary jit-lock chunk end.
Use the new function directly in several places where c-forward-token-2
wouldn't move over the last token in the buffer. This caused an infinite loop
in c-restore-<>-properties.
* lisp/progmodes/cc-engine.el (c-forward-over-token-and-ws): New function,
extracted from c-forward-token-2.
(c-forward-token-2): Refactor, calling the new function.
(c-restore-<>-properties): Fix infinite loop.
(c-forward-<>-arglist-recur, c-in-knr-argdecl)
(c-looking-at-or-maybe-in-bracelist): Call the new function directly in place
of c-forward-token-2.
* lisp/progmodes/cc-cmds.el (c-defun-name) Call the new function directly in
place of c-forward-token-2.
* lisp/progmodes/cc-fonts.el (c-font-lock-enclosing-decls): Call the new
function directly in place of c-forward-token-2.
* lisp/progmodes/cc-fonts.el (c-font-lock-declarators): Introduce a new
optional parameter, template-class. In "class <X = Y>", fontify "Y" as a
type.
(c-font-lock-single-decl): New variable template-class, set to non-nil when we
have a construct like the above. Pass this as argument to
c-font-lock-declarators.
(c-font-lock-cut-off-declarators): Check more rigorously that a declaration
being processed starts before the function's starting position.
(c-complex-decl-matchers): Remove the redundant clause which fontified "types
preceded by, e.g., "struct"".
* lisp/progmodes/cc-langs.el (c-template-typename-kwds)
(c-template-typename-key): New lang defconsts and defvar.
Most of this change is to boilerplate commentary such as license URLs.
This change was prompted by ftp://ftp.gnu.org's going-away party,
planned for November. Change these FTP URLs to https://ftp.gnu.org
instead. Make similar changes for URLs to other organizations moving
away from FTP. Also, change HTTP to HTTPS for URLs to gnu.org and
fsf.org when this works, as this will further help defend against
man-in-the-middle attacks (for this part I omitted the MS-DOS and
MS-Windows sources and the test tarballs to keep the workload down).
HTTPS is not fully working to lists.gnu.org so I left those URLs alone
for now.
* lisp/progmodes/cc-fonts.el (c-font-lock-enclosing-decls): abolish the
spurious check that the character before the start of an enclosed declaration
must be ; or }. It might also be {.
The problem here happened when an "outer list" of declarations moved beyond an
"inner list" containing class initializers. These weren't being checked for
by the code.
Also, fix places in c-get-fontification-context where point is undefined.
* lisp/progmodes/cc-fonts.el (c-get-fontification-context): when argument
not-front-decl is set, test for class initializers. Also, anchor point in
places where it is moved and is otherwise undefined.
The error happened when there was a comma inside template delimiters.
* lisp/progmodes/cc-fonts.el (c-get-fontification-context): In "for"
statements, recognise template delimiters containing "," and "&".
Single quotes, even in strings and comments, are now marked with the
"punctuation" syntax-table property, except where they are validly bounding a
character literal. They are font locked with font-lock-warning-face except
where they are valid. This is done in C, C++, ObjC, and Java Modes.
* lisp/progmodes/cc-defs.el (c-clear-char-property-with-value-on-char-function)
(c-clear-char-property-with-value-on-char, c-put-char-properties-on-char): New
functions/macros.
* lisp/progmodes/cc-fonts.el (c-font-lock-invalid-single-quotes): New function.
(c-basic-matchers-before): invoke c-font-lock-invalid-single-quotes.
* lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Remove
c-before-after-change-digit-quote from wherever it occurs. Insert
c-parse-quotes-before-change into the entries for the languages where it is
needed.
(c-before-font-lock-functions): Remove c-before-after-change-digit-quote from
wherever it occurs. Insert c-parse-quotes-after-change into the entries for
the languages which need it.
(c-has-quoted-numbers): New lang-defconst/-defvar.
* lisp/progmodes/cc-mode.el (c-before-after-change-digit-quote): Remove.
(c-maybe-quoted-number-head, c-maybe-quoted-number-tail)
(c-maybe-quoted-number): New defconsts.
(c-quoted-number-head-before-point, c-quoted-number-tail-after-point)
(c-quoted-number-straddling-point, c-parse-quotes-before-change)
(c-parse-quotes-after-change): New functions.
* lisp/progmodes/cc-cmds.el (c-declaration-limits): Remove unused local
variable.
* lisp/progmodes/cc-defs.el (c--mapcan-status): Remove.
(c--cl-library): New variable.
(Top level): Amend the form which requires library cl or cl-lib.
(c--mapcan, c--set-difference, c--intersection, c--macroexpand-all)
(c--delete-duplicate): Amend to use c--cl-library instead of
c--mapcan-status.
* lisp/progmodes/cc-engine.el (c-syntactic-skip-backward)
(c-back-over-compound-identifier): Remove unused local variables.
* lisp/progmodes/cc-fonts.el (c-font-lock-declarations): Remove an unused
local variable.
* lisp/progmodes/cc-langs.el (Top level): Amend to use c--cl-library instead
of c--mapcan-status.
* lisp/progmodes/cc-styles.el (Top level): Add a cc-bytecomp-defun to try to
silence a compiler warning.
* lisp/progmodes/cc-cmds.el (c-block-comment-flag): Move declaration to solve
compiler warning.
* lisp/progmodes/cc-fonts.el (c-get-fontification-context): Add an extra
clause to handle C++ member initialization lists.
(c-font-lock-single-decl): New function, extracted from
c-font-lock-declarations.
(c-font-lock-declarations): Call c-font-lock-single-decl in place of inline
code.
(c-font-lock-cut-off-declarators): Make more rigorous by calling
c-get-fontification-context, c-forward-decl-or-cast-1, and
c-font-lock-single-decl in place of rather approximate code.
* lisp/progmodes/cc-engine.el (c-find-decl-spots): Initialize
cfd-top-level properly.
(c-forward-decl-or-cast-1): On finding FOO::FOO, check it is followed by "("
before deciding it is a constructor.
* lisp/progmodes/cc-fonts.el (c-font-lock-complex-decl-prepare): Negate the
result of the c-bs-at-toplevel-p call passed to c-font-lock-declarators
(simple bug fix).
Also implement the "asymmetric space" rule for fontifying otherwise
ambiguous
declarations/expressions.
* lisp/progmodes/cc-engine.el (c-before-change-check-<>-operators): Don't set
c-new-BEG or c-new-END when there is no need.
(c-forward-decl-or-cast-1): Add "CASE 17.5" to implement the "asymmetric
space" rule.
* lisp/progmodes/cc-fonts.el (c-get-fontification-context): New function,
extracted from c-font-lock-declarations. Add to this function processing to
make `context' 'decl for lines contained within parens when these are also
declarations.
(c-font-lock-declarations): Call the newly extracted function above in place
of inline code.
* lisp/progmodes/cc-mode.el (c-fl-decl-start): Set point before calling
c-literal-start.
* lisp/progmodes/cc-vars.el (c-asymmetry-fontification-flag): New user option.
* doc/misc/cc-mode.texi (Misc Font Locking): New node documenting the new
"asymmetric fontification" rule, including the variable
c-asymmetric-fontification-flag.
The "enum" was in an argument list, but triggered the fontification of a
following identifier in the function block as though it were in an enum
declaration.
* lisp/progmodes/cc-fonts.el (c-font-lock-enum-body): New function.
(c-basic-matchers-after): Replace the inline stanza for enum elements with a
call to c-font-lock-enum-body.
* lisp/progmodes/cc-langs.el (c-enum-clause-introduction-re): New language
variable.
This problem is caused by the fundamental ambiguity in C++ between
argument declarations and initialisation clauses.
* lisp/progmodes/cc-fonts.el (c-font-lock-declarations): If we have an open
paren preceded by an arithmetic operator, we give this the context nil, not
'arglist.
* lisp/progmodes/cc-langs.el (c-arithmetic-operators, c-arithmetic-op-regexp):
New lang consts and vars.
Or, more clearly, when something looks like a function declaration and it's
inside a function, fontify it as a direct initialization.
For this purpose, introduce a "brace stack" for each buffer, where an entry on
the brace stack states how deeply nested a particular position is inside
braces inside a "top level", which includes classes and namespaces.
Also introduce a new "context", "top", with which c-font-lock-declarations
signals to c-forward-decl-or-cast-1 that point is at the top level.
* lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): add
c-truncate-bs-cache.
(c-flat-decl-block-kwds, c-brace-stack-thing-key, c-brace-stack-no-semi-key)
(c-type-decl-operator-prefix-key): new language constants/variables.
* lisp/progmodes/cc-engine.el (c-bs-interval, c-bs-cache, c-bs-cache-limit)
(c-bs-prev-pos, c-bs-prev-stack): New mostly local variables for the brace
stack cache.
(c-init-bs-cache, c-truncate-bs-cache, c-truncate-bs-cache, c-brace-stack-at)
(c-bs-at-toplevel-p): New functions which manipulate the brace stack (cache).
(c-find-decl-prefix-search): Keep track of whether we're at top level.
(c-find-decl-spots): New local variable cfd-top-level which records what it
says. On calling cfd-fun, pass cfd-top-level as an additional argument.
(c-forward-declarator): Add new element DECORATED to the result list. Set it
to non-nil when a match for c-type-decl-operator-prefix-key is found.
(c-forward-decl-or-cast-1): Handle the newly introduced context "top".
Introduce "CASE 9.5", which recognizes direct initializations.
* lisp/progmodes/cc-fonts.el (c-font-lock-complex-decl-prepare)
(c-font-lock-enum-tail, c-font-lock-cut-off-declarators)
(c-font-lock-enclosing-decls, c-simple-decl-matchers, c-basic-matchers-after):
Add appropriate `not-top' argument to calls to c-font-lock-declarators.
(c-font-lock-declarators): Additional parameter `not-top'. Use not-top to
participate in the decision whether to fontify an identifier as a function or
a variable.
(c-font-lock-declarations): The internal lambda function takes an additional
argument `toplev' from c-find-decl-spots, which it uses in determining the
"context" of a declaration. Add appropriate `not-top' argument to calls to
c-font-lock-declarators.
(c-font-lock-objc-methods): Add extra parameter to internal lambda function,
like for c-font-lock-declarators.
* lisp/progmodes/cc-mode.el (c-basic-common-init): Initialize the brace stack
cache.