bug#58883:

Po Lu via CC-Mode-help <[email protected]> Tue, 08 Nov 2022 20:29:30 +0800
Newsgroups gmane.emacs.cc-mode.general
Message-ID <[email protected]>
Alan Mackenzie <[email protected]> writes:

> I'm gradually fixing it.

Thanks.  I hope Emacs 29 will not be released without the fix.

> The mechanism is that when C Mode sees what it takes to be a type, from
> the context, c-forward-type returns the symbol 'maybe.
>
> Later on in the processing, the analysis of the C code "confirms" that
> this 'maybe actually is a type, and it gets promoted to 'found, and
> entered into the c-found-types list.  At the same time, other occurrences
> of the type throughout the buffer are fontified as types.
>
> This mechanism is not foolproof, and goes wrong when a statement is
> partially typed.  Rather than correcting the mistakenly fontified
> "types", which would be more difficult, I'm concentrating on not
> promoting a 'maybe type to a 'found type too enthusiasically.

Right, but there are some things that simply cannot work with that
approach.  Imagine the following code being typed by the user:

foo (ptr)
     struct foobar *ptr;
{
  register struct frobar *ptr_fast;

  ptr_fast = ptr;

only for him to realize that "oops, struct frobar is not a type!" and
correct it to:

  register struct foobar *ptr_fast;

by which time it is too late, and "struct frobar" is now in
c-found-types, with all the ensuing consequences.

> The problem here is that CC Mode isn't a compiler, and doesn't do very
> deep analysis on the source.  The new mode with tree sitter will likely
> do much better on such troublesome sources in the future.  Sorry!

But it worked fine in Emacs 28...