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

Alan Mackenzie <[email protected]> Sat, 15 Oct 2022 09:38:15 +0000
Newsgroups gmane.emacs.cc-mode.general
Message-ID <Y0p/h6p33jh8LMiZ@ACM>
Hello, Po.

On Sat, Oct 15, 2022 at 10:32:45 +0800, Po Lu wrote:
> Package: cc-mode

> Insert the following text in a new buffer:

> dm_window_deform_around_cursor (window, wl_surface, wl_pointer)
>      dm_window_ptr window;
>      struct wl_surface *wl_surface;
>      struct wl_pointer *wl_pointer;
> {
>   dm_transform_data_ptr data;
>   dm_wayland_seat_ptr seat;
>   int rc;
>   register int DECLARE_FIXED_32_32_4 (shx, shy, tx, ty);

>   data = dm_get_window_private (window, sizeof (dm_transform_data_rec),
> 				init_dm_transform_data);

>   /* Private code elided.  */

>   return rc;
> }

> then, enable c-mode in that buffer.  The wl_surface and wl_pointer
> arguments will be fontified as types, which doesn't happen in Emacs 28.

> (The joys of porting old code to Wayland!)

> The bug also happens even if the code is written as follows:

> int
> dm_window_deform_around_cursor (dm_window_ptr window,
> 				struct wl_surface *wl_surface,
> 				struct wl_pointer *wl_pointer)
> {
>   dm_transform_data_ptr data;
>   int rc;
>   float shx, shy, tx, ty;

>   data = dm_get_window_private (window, sizeof (dm_transform_data_rec),
> 				init_dm_transform_data);

>   /* Private code elided.  */

>   return rc;
> }

[ .... ]

Thanks for the bug report, thanks also for the CC Mode configuration
dump.

I think I know what's causing the bug; With "struct wl_surface", CC Mode
decides "wl_surface" is a type, and thus fontifies occurrences of
"wl_surface" as types.  Unfortunately, there are variables of this name,
too.

Give me a little time, and I will come up with a solution.

-- 
Alan Mackenzie (Nuremberg, Germany).