aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2023-04-05 13:02:12 +0000
committerAlan Mackenzie2023-04-05 13:02:12 +0000
commita42f4a775bab61581d6b8dbd4fe2eeab55a6ea31 (patch)
tree850fa208c92cbfb285f070fa9dbefb9450e246ac
parent8678708ad10b17a4609c950a02cf39ab9ff86317 (diff)
downloademacs-a42f4a775bab61581d6b8dbd4fe2eeab55a6ea31.tar.gz
emacs-a42f4a775bab61581d6b8dbd4fe2eeab55a6ea31.zip
CC Mode: Fix fontification problems shown by test file templates-20.cc
Also fix one problem evident in test file decls-10.cc. * lisp/progmodes/cc-engine.el (c-brace-stack-at): Bind c-record-type-identifiers to nil to prevent called functions recording identifiers spuriously. (c-forward-<>-arglist-recur): Revert the ill-advised optimization from autumn 2022 which attempted to avoid re-marking c-type text properties inside angle bracket arglists. (c-forward-decl-or-cast-1): Accept the semicolon at the end of "t8 * id;" as sufficient evidence to fontify as a declaration (not a multiplication). * lisp/progmodes/cc-fonts.el (c-font-lock-c++-using): No longer fontify the last component of foo::bar with c-reference-face-name.
-rw-r--r--lisp/progmodes/cc-engine.el24
-rw-r--r--lisp/progmodes/cc-fonts.el4
2 files changed, 12 insertions, 16 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 81446c3c00b..fe9e62ee569 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -146,11 +146,6 @@
146;; "typedef" keyword. It's value is a list of the identifiers that 146;; "typedef" keyword. It's value is a list of the identifiers that
147;; the "typedef" declares as types. 147;; the "typedef" declares as types.
148;; 148;;
149;; 'c-<>-c-types-set
150;; This property is set on an opening angle bracket, and indicates that
151;; any "," separators within the template/generic expression have been
152;; marked with a 'c-type property value 'c-<>-arg-sep (see above).
153;;
154;; 'c-awk-NL-prop 149;; 'c-awk-NL-prop
155;; Used in AWK mode to mark the various kinds of newlines. See 150;; Used in AWK mode to mark the various kinds of newlines. See
156;; cc-awk.el. 151;; cc-awk.el.
@@ -6172,12 +6167,18 @@ comment at the start of cc-engine.el for more info."
6172 (cons (point) 6167 (cons (point)
6173 (cons bound-<> s))))) 6168 (cons bound-<> s)))))
6174 6169
6170(defvar c-record-type-identifiers) ; Specially for `c-brace-stack-at'.
6171
6175(defun c-brace-stack-at (here) 6172(defun c-brace-stack-at (here)
6176 ;; Given a buffer position HERE, Return the value of the brace stack there. 6173 ;; Given a buffer position HERE, Return the value of the brace stack there.
6177 (save-excursion 6174 (save-excursion
6178 (save-restriction 6175 (save-restriction
6179 (widen) 6176 (widen)
6180 (let ((c c-bs-cache) 6177 (let (c-record-type-identifiers ; In case `c-forward-<>-arglist' would
6178 ; otherwise record identifiers outside
6179 ; of the restriction in force before
6180 ; this function.
6181 (c c-bs-cache)
6181 (can-use-prev (<= c-bs-prev-pos c-bs-cache-limit)) 6182 (can-use-prev (<= c-bs-prev-pos c-bs-cache-limit))
6182 elt stack pos npos high-elt) 6183 elt stack pos npos high-elt)
6183 ;; Trim the cache to take account of buffer changes. 6184 ;; Trim the cache to take account of buffer changes.
@@ -8630,11 +8631,9 @@ multi-line strings (but not C++, for example)."
8630 ;; List that collects the positions after the argument 8631 ;; List that collects the positions after the argument
8631 ;; separating ',' in the arglist. 8632 ;; separating ',' in the arglist.
8632 arg-start-pos) 8633 arg-start-pos)
8633 ;; If the '<' has paren open syntax then we've marked it as an angle 8634 (if (and (not c-parse-and-markup-<>-arglists)
8634 ;; bracket arglist before, so skip to the end. 8635 syntax-table-prop-on-<)
8635 (if (and syntax-table-prop-on-< 8636
8636 (or (not c-parse-and-markup-<>-arglists)
8637 (c-get-char-property (point) 'c-<>-c-types-set)))
8638 (progn 8637 (progn
8639 (forward-char) 8638 (forward-char)
8640 (if (and (c-go-up-list-forward) 8639 (if (and (c-go-up-list-forward)
@@ -8731,7 +8730,6 @@ multi-line strings (but not C++, for example)."
8731 (c-unmark-<->-as-paren (point))))) 8730 (c-unmark-<->-as-paren (point)))))
8732 (c-mark-<-as-paren start) 8731 (c-mark-<-as-paren start)
8733 (c-mark->-as-paren (1- (point))) 8732 (c-mark->-as-paren (1- (point)))
8734 (c-put-char-property start 'c-<>-c-types-set t)
8735 (c-truncate-lit-pos-cache start)) 8733 (c-truncate-lit-pos-cache start))
8736 (setq res t) 8734 (setq res t)
8737 nil)) ; Exit the loop. 8735 nil)) ; Exit the loop.
@@ -11200,7 +11198,7 @@ This function might do hidden buffer changes."
11200 ;; declaration. 11198 ;; declaration.
11201 (setq maybe-expression t) 11199 (setq maybe-expression t)
11202 (when (or (not c-asymmetry-fontification-flag) 11200 (when (or (not c-asymmetry-fontification-flag)
11203 (looking-at "=[^=]") 11201 (looking-at "=\\([^=]\\|$\\)\\|;")
11204 (c-fdoc-assymetric-space-about-asterisk)) 11202 (c-fdoc-assymetric-space-about-asterisk))
11205 (when (eq at-type 'maybe) 11203 (when (eq at-type 'maybe)
11206 (setq unsafe-maybe t)) 11204 (setq unsafe-maybe t))
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index f726fef467e..17b3c7be199 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -2678,9 +2678,7 @@ need for `c-font-lock-extra-types'.")
2678 'same) 2678 'same)
2679 (looking-at c-colon-type-list-re))) 2679 (looking-at c-colon-type-list-re)))
2680 ;; Inherited protected member: leave unfontified 2680 ;; Inherited protected member: leave unfontified
2681 ) 2681 ))
2682 (t (goto-char pos)
2683 (c-font-lock-declarators limit nil c-label-face-name nil)))
2684 (eq (char-after) ?,))) 2682 (eq (char-after) ?,)))
2685 (forward-char))) ; over the comma. 2683 (forward-char))) ; over the comma.
2686 nil)) 2684 nil))