Subject: Re: bug#63224: CC Mode 5.35.2 (C/*l); ``extern foo ()'' not fontified correctly

From: Alan Mackenzie <[email-masked]>
Date: Tue, 2 May 2023 17:24:30 +0000

Hello, Po.

Thanks for the high quality bug report.

On Tue, May 02, 2023 at 15:31:51 +0800, Po Lu via CC-Mode-help wrote:
> Package: cc-mode

> Insert:

> main ()
> {
>   extern foo ();

>   foo ("hello world!\n");
> }

> in a C Mode buffer.  Notice that the identifier in the declarator of
> `foo' is not fontified as a function.

> Emacs  : GNU Emacs 29.0.90 (build 1, x86_64-pc-linux-gnu)
>  of 2023-04-29
> Package: CC Mode 5.35.2 (C/*l)
> Buffer Style: gnu
> c-emacs-features: (pps-extended-state col-0-paren posix-char-classes gen-string-delim gen-comment-delim syntax-properties category-properties 1-bit)

[ .... ]

This was a special case which wasn't being handled.

Would you please try the attached patch on your real C code, and let me
know how well it works.  It should apply cleanly to either the emacs-29
branch or the trunk.

Thanks!

-- 
Alan Mackenzie (Nuremberg, Germany).

diff -r 5d3dbc9b0ca3 cc-engine.el
--- a/cc-engine.el	Fri Apr 14 16:10:23 2023 +0000
+++ b/cc-engine.el	Tue May 02 17:09:14 2023 +0000
@@ -9300,7 +9300,11 @@
 	     (setq pos (point))
 	     (c-forward-syntactic-ws)
 	     (and (not (looking-at c-symbol-start))
-		  (not (looking-at c-type-decl-prefix-key)))))
+		  (or
+		   (not (looking-at c-type-decl-prefix-key))
+		   (and (eq (char-after) ?\()
+			(not (save-excursion
+			       (c-forward-declarator))))))))
       ;; A C specifier followed by an implicit int, e.g.
       ;; "register count;"
       (goto-char prefix-end-pos)