From: Alan Mackenzie Date: Tue, 8 Nov 2022 11:53:37 +0000 (+0000) Subject: CC Mode: Stabilize the fontification in the presence of "register" keywords X-Git-Tag: emacs-29.0.90~1616^2~244 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b8134a7eba2e0334925e011e953044ea33408ec6;p=emacs.git CC Mode: Stabilize the fontification in the presence of "register" keywords This fixes bug #58883. * lisp/progmodes/cc-engine.el (c-forward-decl-or-cast-1): New variable unsafe-maybe. Set it in CASE 10 rather than setting c-record-type-identifiers to nil. Near the end of the function, when unsafe-maybe is set, bind c-promote-possible-types to 'just-one rather than t around the call to c-forward-type. --- diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 8cf882d5699..145f0cacd13 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -10208,7 +10208,11 @@ This function might do hidden buffer changes." (save-rec-ref-ids c-record-ref-identifiers) ;; Set when we parse a declaration which might also be an expression, ;; such as "a *b". See CASE 16 and CASE 17. - maybe-expression) + maybe-expression + ;; Set for the type when `c-forward-type' returned `maybe', and we + ;; want to fontify it as a type, but aren't confident enough to enter + ;; it into `c-found-types'. + unsafe-maybe) (save-excursion (goto-char preceding-token-end) @@ -10904,7 +10908,7 @@ This function might do hidden buffer changes." ;; a statement beginning with an identifier. (when (and (eq at-type 'maybe) (not (eq context 'top))) - (setq c-record-type-identifiers nil)) + (setq unsafe-maybe t)) (throw 'at-decl-or-cast t)) ;; CASE 11 @@ -11207,7 +11211,8 @@ This function might do hidden buffer changes." ;; fontification just because it's "a known type that can't ;; be a name or other expression". 2013-09-18. ) - (let ((c-promote-possible-types t)) + (let ((c-promote-possible-types + (if unsafe-maybe 'just-one t))) (save-excursion (goto-char type-start) (c-forward-type))))