Subject: Re: bug#24246: 25.0.95; (c++-mode) custom/extra types not getting highlighted (as a type) after a wrapper::type argument.

From: Alan Mackenzie <[email-masked]>
Date: Wed, 17 Aug 2016 18:21:21 +0000

Hello again, Arash.

On Wed, Aug 17, 2016 at 01:24:17AM +0430, Arash wrote:
> $ emacs -Q ab.cc

> typedef int int32;

> namespace wrapper {
>     enum type { a, b, c };
> }

> // int32 doesn't get highlighted as a type.
> void test(wrapper::type A, int32 B);

> typedef wrapper::type wtype;

> // here it works, so double colon is the problem?
> void test(wtype A, int32 B);

Thanks indeed for this bug report, and thanks even more for cutting it
down to a nice, crisp, manageable file.

The fontification code was not handling "::" in declarations correctly.
I think I have corrected this, and I have committed it to our master
branch at savannah.

I see you're on the emacs-25 branch.  Could you please patch your Emacs
with the following patch (the file is in directory .../lisp/progmodes),
rebuild CC Mode (a single $ emacs -Q -batch -f batch-byte-compile
.../lisp/progmodes/cc-engine.el should suffice), reload CC Mode into
your Emacs (or restart Emacs), then try out the new system on your real
code.

Then please let me know whether the problem has been truly fixed, and
if not, what is still wrong.  If everything is OK, I will close the bug.

Here's the patch:

# HG changeset patch
# User Alan Mackenzie <[email-masked]>
# Date 1471456447 0
#      Wed Aug 17 17:54:07 2016 +0000
# Node ID 85afa8e79cc145c4ab61d8c8f180587d85c71bec
# Parent  0e89dd90ade9cd6f5f4ca07cb57cba6f8e1335a5
Fontify constructs following "::" in C++ argument lists correctly.

This fixes bug #24246.

* cc-engine.el (c-find-decl-prefix-search): In the "pseudo match" loop, test a
found string for a match with c-opt-identifier-concat-key (e.g. with "::").

* arglist-23.{cc,face}: New test files.

diff -r 0e89dd90ade9 -r 85afa8e79cc1 cc-engine.el
--- a/cc-engine.el	Wed Aug 17 17:53:10 2016 +0000
+++ b/cc-engine.el	Wed Aug 17 17:54:07 2016 +0000
@@ -5171,6 +5171,13 @@
 			(and (< (point) cfd-limit)
 			     (c-got-face-at (point) c-literal-faces))))
 	       t)		      ; Continue the loop over pseudo matches.
+	      ((and c-opt-identifier-concat-key
+		    (match-string 1)
+		    (save-excursion
+		      (goto-char (match-beginning 1))
+		      (looking-at c-opt-identifier-concat-key)))
+	       ;; Found, e.g., "::" in C++
+	       t)
 	      ((and (match-string 1)
 		    (string= (match-string 1) ":")
 		    (save-excursion

-- 
Alan Mackenzie (Nuremberg, Germany).