bug#58537: CC Mode 5.35.1 (C/*l); Keywords being fontified as types at random
Alan Mackenzie <[email protected]> Wed, 19 Oct 2022 12:47:07 +0000
| Newsgroups | gmane.emacs.cc-mode.general |
|---|---|
| Message-ID | <Y0/xy3A/fYJ3kYAV@ACM> |
Hello again, Po. On Wed, Oct 19, 2022 at 18:27:34 +0800, Po Lu wrote: > Alan Mackenzie <[email protected]> writes: > > I think the patch solves #58537 together with the problems you reported > > since. Does it also solve #58539? > Yes, it does, .... That's fantastic! > .... but there's still an unsolved problem: > test () > { > dm_window_ptr window; > window = id_private_fetch (); > if (window) > } > if this is edited into: > test () > { > dm_window_ptr window; > window = id_private_fetch (); > if ((window)addr window) > } > which is not valid C, but still something that can happen while typing a > program, and it is then edited into: > test () > { > dm_window_ptr window; > window = id_private_fetch (); > if ((window_addr) window) > } > "window" in the line above the "if" remains fontified as a type. Sorry, you mentioned this before, and I didn't get around to fixing it. Would you please try applying the attached patch on top of the earlier patch from this morning (for me)/afternoon (for you). If this works OK, then I propose linking bugs #58537 and #58539 and closing them. Thanks for being so patient and insistent over the last few days. > Thanks. -- Alan Mackenzie (Nuremberg, Germany).
diff.20221019b.diff
(text/plain, 548 B)
diff -r dbe2661a4298 cc-engine.el
--- a/cc-engine.el Mon Oct 17 20:12:54 2022 +0000
+++ b/cc-engine.el Wed Oct 19 12:33:58 2022 +0000
@@ -11143,7 +11161,10 @@
(not (c-on-identifier)))))))))
;; Handle the cast.
- (when (and c-record-type-identifiers at-type (not (eq at-type t)))
+ (when (and c-record-type-identifiers
+ at-type
+ (not (memq at-type '(t maybe)))) ; 'maybe isn't strong enough
+ ; evidence to promote the type.
(let ((c-promote-possible-types t))
(goto-char type-start)
(c-forward-type)))