aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas2023-01-20 11:30:22 +0100
committerStefan Kangas2023-01-20 11:30:22 +0100
commite9ceeee1198aa10cac3cd61ff9537b64640455c2 (patch)
treef9d61bb3192116e89da92e6117e29d4c3bf34a18
parent117f90865adca03eab84778db0370ddc05ba8ae7 (diff)
parent21be03cccb611ea9e6c73fb04e578c48edf49a25 (diff)
downloademacs-e9ceeee1198aa10cac3cd61ff9537b64640455c2.tar.gz
emacs-e9ceeee1198aa10cac3cd61ff9537b64640455c2.zip
Merge from origin/emacs-29
21be03cccb6 CC Mode: Prevent two classes of "type" prematurely enteri...
-rw-r--r--lisp/progmodes/cc-engine.el42
1 files changed, 31 insertions, 11 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 3fa407dd338..ebcb20f0f8c 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -10475,6 +10475,8 @@ This function might do hidden buffer changes."
10475 got-prefix 10475 got-prefix
10476 ;; True if the declarator is surrounded by a parenthesis pair. 10476 ;; True if the declarator is surrounded by a parenthesis pair.
10477 got-parens 10477 got-parens
10478 ;; True if there is a terminated argument list.
10479 got-arglist
10478 ;; True if there is an identifier in the declarator. 10480 ;; True if there is an identifier in the declarator.
10479 got-identifier 10481 got-identifier
10480 ;; True if we find a number where an identifier was expected. 10482 ;; True if we find a number where an identifier was expected.
@@ -10622,13 +10624,17 @@ This function might do hidden buffer changes."
10622 (when (> paren-depth 0) 10624 (when (> paren-depth 0)
10623 (setq paren-depth (1- paren-depth)) 10625 (setq paren-depth (1- paren-depth))
10624 (forward-char) 10626 (forward-char)
10627 (when (and (not got-parens)
10628 (eq paren-depth 0))
10629 (setq got-arglist t))
10625 t) 10630 t)
10626 (when (if (save-match-data (looking-at "\\s(")) 10631 (when (cond
10627 (c-safe (c-forward-sexp 1) t) 10632 ((save-match-data (looking-at "\\s("))
10628 (if (save-match-data 10633 (c-safe (c-forward-sexp 1) t))
10629 (looking-at c-fun-name-substitute-key)) ; requires 10634 ((save-match-data
10630 (c-forward-c++-requires-clause) 10635 (looking-at c-fun-name-substitute-key)) ; C++ requires
10631 (goto-char (match-end 1)) 10636 (c-forward-c++-requires-clause))
10637 (t (goto-char (match-end 1))
10632 t)) 10638 t))
10633 (when (and (not got-suffix-after-parens) 10639 (when (and (not got-suffix-after-parens)
10634 (= paren-depth 0)) 10640 (= paren-depth 0))
@@ -10690,8 +10696,11 @@ This function might do hidden buffer changes."
10690 (goto-char pos) 10696 (goto-char pos)
10691 (setq pd (1- pd))) 10697 (setq pd (1- pd)))
10692 t))) 10698 t)))
10693 (c-fdoc-shift-type-backward) 10699 (c-fdoc-shift-type-backward)
10694 t))) 10700 (when (and (not got-parens)
10701 (eq paren-depth 0))
10702 (setq got-arglist t))
10703 t)))
10695 10704
10696 (c-forward-syntactic-ws)) 10705 (c-forward-syntactic-ws))
10697 10706
@@ -10759,6 +10768,9 @@ This function might do hidden buffer changes."
10759 (not (or got-prefix got-parens))) 10768 (not (or got-prefix got-parens)))
10760 ;; Got another identifier directly after the type, so it's a 10769 ;; Got another identifier directly after the type, so it's a
10761 ;; declaration. 10770 ;; declaration.
10771 (when (and got-arglist
10772 (eq at-type 'maybe))
10773 (setq unsafe-maybe t))
10762 (throw 'at-decl-or-cast t)) 10774 (throw 'at-decl-or-cast t))
10763 10775
10764 (when (and got-parens 10776 (when (and got-parens
@@ -11147,9 +11159,17 @@ This function might do hidden buffer changes."
11147 ;; inside an arglist that contains declarations. Update (2017-09): We 11159 ;; inside an arglist that contains declarations. Update (2017-09): We
11148 ;; now recognize a top-level "foo(bar);" as a declaration in C. 11160 ;; now recognize a top-level "foo(bar);" as a declaration in C.
11149 ;; CASE 19 11161 ;; CASE 19
11150 (or (eq context 'decl) 11162 (when
11151 (and (c-major-mode-is 'c-mode) 11163 (or (eq context 'decl)
11152 (or (eq context 'top) make-top)))))) 11164 (and (c-major-mode-is 'c-mode)
11165 (or (eq context 'top) make-top)))
11166 (when (and (eq at-type 'maybe)
11167 got-parens)
11168 ;; If we've got "foo d(bar () ...)", the d could be a typing
11169 ;; mistake, so we don't promote the 'maybe type "bar" to a 'found
11170 ;; type.
11171 (setq unsafe-maybe t))
11172 t))))
11153 11173
11154 ;; The point is now after the type decl expression. 11174 ;; The point is now after the type decl expression.
11155 11175