bug#58537: CC Mode 5.35.1 (C/*l); Keywords being fontified as types at random

Po Lu via CC-Mode-help <[email protected]> Sun, 16 Oct 2022 15:20:49 +0800
Newsgroups gmane.emacs.cc-mode.general
Message-ID <[email protected]>
Po Lu <[email protected]> writes:

> Package: cc-mode
>
> Sometimes, immediately before typing the closing parentheses of a
> function invocation, like so:
>
> void
> dm_apply_screen_again (window, drawable, root_x, root_y)
>      dm_root_window_ptr window;
>      dm_root_window_drawable_ptr drawable;
> {
>   dm_lock_type type;
>   dm_screen_ptr screen;
> #if 1
>   dm_tgs_reply_ptr client_data;
> #else
>   caddr_t client_data;
> #endif
>   dm_screen_lock_ptr lock;
>
>   /* Private code elided.  */
>
>   dm_apply_pointer_lock (window, lock
>
> every occurrence of "lock", "root_x", and "root_y" in the file becomes
> fontified as a type, and is stuck that way.  The only way to stop those
> keywords from being fontified as types is by reenabling c-mode.
>
> This did not happen in Emacs 28; I can't reproduce the bug with a file
> that I can share, but I will keep trying to make one.

I think I have a reproducible recipe for this now, which I got while
working on a completely different program.

First, insert the following text in a buffer:

RelativePointer *
XLSeatGetRelativePointer (Seat *seat, struct wl_resource *resource)
{
  RelativePointer *relative_pointer;
  SeatClientInfo *info;

  /* Create a relative pointer object for the relative pointer
     resource RESOURCE.  */

  relative_pointer = XLCalloc (1, sizeof *relative_pointer);
  info = CreateSeatClientInfo (wl_resource_get_client (resource));

  /* Link the relative pointer onto the seat client info.  */
  relative_pointer->next = info->relative_pointers.next;
  relative_pointer->last = &info->relative_pointers;

  /* Then, the seat.  */
  relative_pointer->seat = seat;
  RetainSeat (seat);
}

then, move to the end of the buffer.  Turn on electric-pair-mode and
c-mode.  Type:

v SPC o SPC i SPC d RET X L S e a t D e s t r o y R e l a t i v e P o i
n t e r SPC ( R e l a t i v e P o i n t e r SPC * r e l a t i v e _ p o
i n t e r C-e

every occurrence `relative_pointer' will be refontified as a type, and
become stuck that way.