Subject: [PATCH] Fontification of function declarators with reference return types is incorrect in c++-ts-mode
From: Daniel Martín <[email-masked]>
To: [email-masked]
Date: Sat, 31 Dec 2022 01:51:02 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Given the following valid C++ code:

class Foo {
public:
        Bar& getBar();
};

c++-ts-mode does not fontify getBar with the
font-lock-function-name-face face.

I've attached a fix to treat reference declarators in
c-ts-mode--declarator-identifier similarly to pointer_declarators.

From 19182746e53ca66dc94aea4a7cd91f67cc7e0aaa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= <[email-masked]>
Date: Sat, 31 Dec 2022 01:45:27 +0100
Subject: [PATCH] Fix fontification of C++ functions with reference return
 types

* lisp/progmodes/c-ts-mode.el (c-ts-fontify-error): Treat
reference_declarator nodes the same as pointer_declarator nodes when
calculating the identifier to fontify.
---
 lisp/progmodes/c-ts-mode.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 82a13e9762..3cb671f4c5 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -425,7 +425,7 @@ c-ts-mode--declarator-identifier
     ;; Recurse.
     ((or "attributed_declarator" "parenthesized_declarator")
      (c-ts-mode--declarator-identifier (treesit-node-child node 0 t)))
-    ("pointer_declarator"
+    ((or "pointer_declarator" "reference_declarator")
      (c-ts-mode--declarator-identifier (treesit-node-child node -1)))
     ((or "function_declarator" "array_declarator" "init_declarator")
      (c-ts-mode--declarator-identifier
-- 
2.34.1