bug#58534: CC Mode 5.35.1 (C/*l); Incorrect fontification of params as types

Po Lu via CC-Mode-help <[email protected]> Sat, 15 Oct 2022 20:23:58 +0800
Newsgroups gmane.emacs.cc-mode.general
Message-ID <[email protected]>
Alan Mackenzie <[email protected]> writes:

> The solution seems to be not to add foo to c-found-types on encountering
> struct foo, but to continue doing so (in C++) for typename foo.
>
> Would you please try out the following patch, and let me know if it
> works OK.  Also could you check whether the patch also fixes bug #58537,
> please.
>
> Thanks!

The patch fixes this bug, but not bug#58537 and bug#58539.  I can't
guess as to what causes bug#58537, but I think bug#58539 is caused by
"if (window)" being somehow momentarily interpreted as a cast, since it
can be reliably reproduced by typing:

  window = id_private_fetch ();
  if ((window) a) <-- this is a typo that makes window look like a cast

I think the best solution would simply be to not add types found inside
casts to c-found-types, especially since "window" is not un-fontified
upon the typo being corrected.