bug#58883: [Was: bug#59032: CC Mode 5.35.1 (C/*l); Incorrect fontification of `subsurface' during typing]

Alan Mackenzie <[email protected]> Tue, 8 Nov 2022 09:37:53 +0000
Newsgroups gmane.emacs.cc-mode.general
Message-ID <Y2ojcR6FsE+fd8Kw@ACM>
Hello, Po.

On Tue, Nov 08, 2022 at 08:25:31 +0800, Po Lu wrote:
> Alan Mackenzie <[email protected]> writes:

[ .... ]

> > I have a fix for this, I think, but it overlaps with an earlier fix to
> > bug #58883.  I sent you a patch on Sunday 2022-10-30 for this earlier
> > bug.  Did you get this patch?  If so, have you any reaction to it?

> I think it got lost in the bulk mail folder (but I can't find it there
> either, so maybe a mailer screwup?)

> So would you please send it again?  TIA.

OK, here it is!

Thanks!

[ I've set the Subject: to bug#58883, and the Cc: to
[email protected]. ]

-- 
Alan Mackenzie (Nuremberg, Germany).
diff.20221030.diff (text/plain, 1.2 KB)
diff -r 53717eda724c cc-engine.el
--- a/cc-engine.el	Sat Oct 29 09:42:47 2022 +0000
+++ b/cc-engine.el	Sun Oct 30 13:32:23 2022 +0000
@@ -10227,7 +10227,11 @@
 	(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)
@@ -10923,7 +10927,7 @@
 	   ;; 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
@@ -11226,7 +11230,8 @@
 		 ;; 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))))