summaryrefslogtreecommitdiff
path: root/lisp/progmodes/cc-fonts.el
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2022-10-19 14:52:14 +0000
committerAlan Mackenzie <acm@muc.de>2022-10-19 14:52:14 +0000
commitfb8276a17c26b4c2bf8281210ede114ff9e24958 (patch)
tree40a9236839bca5717a634eb7d5e5677b4521de21 /lisp/progmodes/cc-fonts.el
parentb96f441139e09d48880e1f20ad4237400529ac5f (diff)
downloademacs-fb8276a17c26b4c2bf8281210ede114ff9e24958.tar.gz
CC Mode: Cease adding types to found-types too eagerly
This fixes bug #58537 and bug #58539. * lisp/progmodes/cc-engine.el (c-forward-type): Remove trailing whitespace from an identifier before passing it to c-add-type. (c-forward-decl-or-cast-1): CASE 3: Do not recognize two consecutive identifiers as type + variable/function unless certain conditions are met. CASE 10: Do not recognize the "type" as a found type unless certain condtions are met. (Near end): Do not recognize the identifier in a cast as a type unless certain conditions are met. * lisp/progmodes/cc-fonts.el (c-get-fontification-context): Recognize being in declaration parens when there is a syntactially wrong "foo ((bar))" preceding the match position. * lisp/progmodes/cc-mode.el (c-update-new-id): Set c-new-id-is-type unconditionally to nil to prevent a second identifier being wrongly marked as a type.
Diffstat (limited to 'lisp/progmodes/cc-fonts.el')
-rw-r--r--lisp/progmodes/cc-fonts.el17
1 files changed, 15 insertions, 2 deletions
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index b4ff32b9070..aa16da70703 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -1197,8 +1197,21 @@ casts and declarations are fontified. Used on level 2 and higher."
;; arguments lists (i.e. lists enclosed by <...>) is more strict about what
;; characters it allows within the list.
(let ((type (and (> match-pos (point-min))
- (c-get-char-property (1- match-pos) 'c-type))))
- (cond ((not (memq (char-before match-pos) '(?\( ?, ?\[ ?< ?{)))
+ (c-get-char-property (1- match-pos) 'c-type)))
+ id-pos)
+ (cond
+ ;; Are we just after something like "(foo((bar))" ?
+ ((and (eq (char-before match-pos) ?\))
+ (c-go-list-backward match-pos)
+ (progn
+ (c-backward-syntactic-ws)
+ (and (setq id-pos (c-on-identifier))
+ (goto-char id-pos)
+ (progn
+ (c-backward-syntactic-ws)
+ (eq (char-before) ?\()))))
+ (c-get-fontification-context (point) not-front-decl toplev))
+ ((not (memq (char-before match-pos) '(?\( ?, ?\[ ?< ?{)))
(cons (and toplev 'top) nil))
;; A control flow expression or a decltype
((and (eq (char-before match-pos) ?\()