Subject: 29.0.50; cc-fonts signals void variable: font-lock-reference-face
From: Stefan Monnier <[email-masked]>
To: [email-masked]
Date: Wed, 19 Oct 2022 14:13:22 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Package: Emacs
Version: 29.0.50

If I start

    % emacs -Q --eval '(make-face `font-lock-reference-face)' -l cc-fonts

I get the error:

    defconst: Symbol’s value as variable is void: font-lock-reference-face

Something like the patch below seems in order.
Not sure if the FIXME is a confusion of mine or is a real problem.

        Stefan

diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index aa16da70703..d8776d8322a 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -146,11 +146,14 @@ c-constant-face-name
 (defconst c-reference-face-name
   (with-no-warnings
    (if (and (c-face-name-p 'font-lock-reference-face)
+	    (boundp 'font-lock-reference-face)
 	    (eq font-lock-reference-face 'font-lock-reference-face))
        ;; This is considered obsolete in Emacs, but it still maps well
        ;; to this use.  (Another reason to do this is to get unique
        ;; faces for the test suite.)
        'font-lock-reference-face
+     ;; FIXME: `font-lock-reference-face' was an alias for
+     ;; `font-lock-constant-face', not `font-lock-label-face'.
      c-label-face-name)))
 
 ;; This should not mapped to a face that also is used to fontify things
@@ -586,7 +589,8 @@ c-fontify-recorded-types-and-refs
 			(c-lang-const c-opt-cpp-macro-define)
 			(c-lang-const c-nonempty-syntactic-ws)
 			"\\(" (c-lang-const ; 1 + ncle + nsws
-			       c-symbol-key) "\\)"
+			       c-symbol-key)
+			"\\)"
 			(concat "\\("	; 2 + ncle + nsws + c-sym-key
 				;; Macro with arguments - a "function".
 				"\\((\\)" ; 3 + ncle + nsws + c-sym-key