diff options
| author | Alan Mackenzie | 2022-09-26 19:16:33 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2022-09-26 19:20:54 +0000 |
| commit | 07e6bbb9bc68f76773e9bdf8846d64d83f50b0ea (patch) | |
| tree | a7c935a05740386446ba0880a99938822e86b3ec | |
| parent | bb83fb5f62aa4b27a5598f4a0a9b22efdd94cf14 (diff) | |
| download | emacs-07e6bbb9bc68f76773e9bdf8846d64d83f50b0ea.tar.gz emacs-07e6bbb9bc68f76773e9bdf8846d64d83f50b0ea.zip | |
CC Mode: Handle C++20 concepts
* lisp/progmodes/cc-align.el (c-lineup-topmost-intro-cont): Amend so as not to
indent lines following a requires line.
* lisp/progmodes/cc-engine.el (c-forward-primary-expression)
(c-forward-c++-requires-clause): New functions.
(c-forward-declarator): Skip forward over any trailing requires clause.
(c-forward-decl-or-cast-1): Skip requires clauses before and after the type.
Amend the second element of the return list to include information on two
consecutive identifiers in <...>.
(c-looking-at-or-maybe-in-bracelist): Don't recognize braces in requires
expressions as brace lists.
(c-guess-basic-syntax): CASE 5D.7: New case to handle the continuation of a
"concept foo = " line.
* lisp/progmodes/cc-fonts.el (c-basic-matchers-before): Add a new clause to
handle the declaration of a concept.
(c-get-fontification-context): Treat the arglist of a requires construct as a
declaration arglist.
* lisp/progmodes/cc-langs.el (c-equals-nontype-decl-kwds/key)
(c-fun-name-substitute-kwds/key, c-pre-concept-<>-kwds/key): New
c-lang-consts/vars.
(c-constant-key): New c-lang-var.
(c-type-decl-suffix-key): Include "requires" in the keywords matched.
* lisp/progmodes/cc-mode.el (c-fl-decl-start): Fix an off by one error. Use
equal rather than eq to compare two syntax contexts.
| -rw-r--r-- | lisp/progmodes/cc-align.el | 13 | ||||
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 149 | ||||
| -rw-r--r-- | lisp/progmodes/cc-fonts.el | 39 | ||||
| -rw-r--r-- | lisp/progmodes/cc-langs.el | 49 | ||||
| -rw-r--r-- | lisp/progmodes/cc-mode.el | 5 |
5 files changed, 226 insertions, 29 deletions
diff --git a/lisp/progmodes/cc-align.el b/lisp/progmodes/cc-align.el index e14f5b9058f..7b45be3c5c1 100644 --- a/lisp/progmodes/cc-align.el +++ b/lisp/progmodes/cc-align.el | |||
| @@ -85,11 +85,14 @@ statement-cont.) | |||
| 85 | Works with: topmost-intro-cont." | 85 | Works with: topmost-intro-cont." |
| 86 | (save-excursion | 86 | (save-excursion |
| 87 | (beginning-of-line) | 87 | (beginning-of-line) |
| 88 | (c-backward-syntactic-ws (c-langelem-pos langelem)) | 88 | (unless (re-search-forward c-fun-name-substitute-key |
| 89 | (if (and (memq (char-before) '(?} ?,)) | 89 | (c-point 'eol) t) |
| 90 | (not (and c-overloadable-operators-regexp | 90 | (beginning-of-line) |
| 91 | (c-after-special-operator-id)))) | 91 | (c-backward-syntactic-ws (c-langelem-pos langelem)) |
| 92 | c-basic-offset))) | 92 | (if (and (memq (char-before) '(?} ?,)) |
| 93 | (not (and c-overloadable-operators-regexp | ||
| 94 | (c-after-special-operator-id)))) | ||
| 95 | c-basic-offset)))) | ||
| 93 | 96 | ||
| 94 | (defun c-lineup-gnu-DEFUN-intro-cont (langelem) | 97 | (defun c-lineup-gnu-DEFUN-intro-cont (langelem) |
| 95 | "Line up the continuation lines of a DEFUN macro in the Emacs C source. | 98 | "Line up the continuation lines of a DEFUN macro in the Emacs C source. |
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 1127ffe2498..e0aef2b2ee6 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -9512,6 +9512,84 @@ point unchanged and return nil." | |||
| 9512 | 9512 | ||
| 9513 | ;; Handling of large scale constructs like statements and declarations. | 9513 | ;; Handling of large scale constructs like statements and declarations. |
| 9514 | 9514 | ||
| 9515 | (defun c-forward-primary-expression (&optional limit) | ||
| 9516 | ;; Go over the primary expression (if any) at point, moving to the next | ||
| 9517 | ;; token and return non-nil. If we're not at a primary expression leave | ||
| 9518 | ;; point unchanged and return nil. | ||
| 9519 | ;; | ||
| 9520 | ;; Note that this function is incomplete, handling only those cases expected | ||
| 9521 | ;; to be common in a C++20 requires clause. | ||
| 9522 | (let ((here (point)) | ||
| 9523 | (c-restricted-<>-arglists t) | ||
| 9524 | (c-parse-and-markup-<>-arglists nil) | ||
| 9525 | ) | ||
| 9526 | (if (cond | ||
| 9527 | ((looking-at c-constant-key) | ||
| 9528 | (goto-char (match-end 1)) | ||
| 9529 | (c-forward-syntactic-ws limit) | ||
| 9530 | t) | ||
| 9531 | ((eq (char-after) ?\() | ||
| 9532 | (and (c-go-list-forward (point) limit) | ||
| 9533 | (eq (char-before) ?\)) | ||
| 9534 | (progn (c-forward-syntactic-ws limit) | ||
| 9535 | t))) | ||
| 9536 | ((c-forward-over-compound-identifier) | ||
| 9537 | (c-forward-syntactic-ws limit) | ||
| 9538 | (while (cond | ||
| 9539 | ((looking-at "<") | ||
| 9540 | (prog1 | ||
| 9541 | (c-forward-<>-arglist nil) | ||
| 9542 | (c-forward-syntactic-ws limit))) | ||
| 9543 | ((looking-at c-opt-identifier-concat-key) | ||
| 9544 | (and | ||
| 9545 | (zerop (c-forward-token-2 1 nil limit)) | ||
| 9546 | (prog1 | ||
| 9547 | (c-forward-over-compound-identifier) | ||
| 9548 | (c-forward-syntactic-ws limit)))))) | ||
| 9549 | t) | ||
| 9550 | ((looking-at c-fun-name-substitute-key) ; "requires" | ||
| 9551 | (goto-char (match-end 1)) | ||
| 9552 | (c-forward-syntactic-ws limit) | ||
| 9553 | (and | ||
| 9554 | (or (not (eq (char-after) ?\()) | ||
| 9555 | (prog1 | ||
| 9556 | (and (c-go-list-forward (point) limit) | ||
| 9557 | (eq (char-before) ?\))) | ||
| 9558 | (c-forward-syntactic-ws))) | ||
| 9559 | (eq (char-after) ?{) | ||
| 9560 | (and (c-go-list-forward (point) limit) | ||
| 9561 | (eq (char-before) ?})) | ||
| 9562 | (progn | ||
| 9563 | (c-forward-syntactic-ws limit) | ||
| 9564 | t)))) | ||
| 9565 | t | ||
| 9566 | (goto-char here) | ||
| 9567 | nil))) | ||
| 9568 | |||
| 9569 | (defun c-forward-c++-requires-clause (&optional limit) | ||
| 9570 | ;; Point is at the keyword "requires". Move forward over the requires | ||
| 9571 | ;; clause to the next token after it and return non-nil. If there is no | ||
| 9572 | ;; valid requires clause at point, leave point unmoved and return nil. | ||
| 9573 | (let ((here (point)) | ||
| 9574 | final-point) | ||
| 9575 | (or limit (setq limit (point-max))) | ||
| 9576 | (if (and | ||
| 9577 | (zerop (c-forward-token-2 1 nil limit)) ; over "requires". | ||
| 9578 | (prog1 | ||
| 9579 | (c-forward-primary-expression limit) | ||
| 9580 | (setq final-point (point)) | ||
| 9581 | (while | ||
| 9582 | (and (looking-at "\\(?:&&\\|||\\)") | ||
| 9583 | (progn (goto-char (match-end 0)) | ||
| 9584 | (c-forward-syntactic-ws limit) | ||
| 9585 | (and (< (point) limit) | ||
| 9586 | (c-forward-primary-expression limit)))) | ||
| 9587 | (setq final-point (point))))) | ||
| 9588 | (progn (goto-char final-point) | ||
| 9589 | t) | ||
| 9590 | (goto-char here) | ||
| 9591 | nil))) | ||
| 9592 | |||
| 9515 | (defun c-forward-declarator (&optional limit accept-anon) | 9593 | (defun c-forward-declarator (&optional limit accept-anon) |
| 9516 | ;; Assuming point is at the start of a declarator, move forward over it, | 9594 | ;; Assuming point is at the start of a declarator, move forward over it, |
| 9517 | ;; leaving point at the next token after it (e.g. a ) or a ; or a ,), or at | 9595 | ;; leaving point at the next token after it (e.g. a ) or a ; or a ,), or at |
| @@ -9565,7 +9643,7 @@ point unchanged and return nil." | |||
| 9565 | ((and (looking-at c-type-decl-prefix-key) | 9643 | ((and (looking-at c-type-decl-prefix-key) |
| 9566 | (if (and (c-major-mode-is 'c++-mode) | 9644 | (if (and (c-major-mode-is 'c++-mode) |
| 9567 | (match-beginning 4)) ; Was 3 - 2021-01-01 | 9645 | (match-beginning 4)) ; Was 3 - 2021-01-01 |
| 9568 | ;; If the third submatch matches in C++ then | 9646 | ;; If the fourth submatch matches in C++ then |
| 9569 | ;; we're looking at an identifier that's a | 9647 | ;; we're looking at an identifier that's a |
| 9570 | ;; prefix only if it specifies a member pointer. | 9648 | ;; prefix only if it specifies a member pointer. |
| 9571 | (progn | 9649 | (progn |
| @@ -9621,6 +9699,11 @@ point unchanged and return nil." | |||
| 9621 | (while (cond | 9699 | (while (cond |
| 9622 | ((looking-at c-decl-hangon-key) | 9700 | ((looking-at c-decl-hangon-key) |
| 9623 | (c-forward-keyword-clause 1)) | 9701 | (c-forward-keyword-clause 1)) |
| 9702 | ((looking-at c-type-decl-suffix-key) | ||
| 9703 | (if (save-match-data | ||
| 9704 | (looking-at c-fun-name-substitute-key)) | ||
| 9705 | (c-forward-c++-requires-clause) | ||
| 9706 | (c-forward-keyword-clause 1))) | ||
| 9624 | ((and c-opt-cpp-prefix | 9707 | ((and c-opt-cpp-prefix |
| 9625 | (looking-at c-noise-macro-with-parens-name-re)) | 9708 | (looking-at c-noise-macro-with-parens-name-re)) |
| 9626 | (c-forward-noise-clause)))) | 9709 | (c-forward-noise-clause)))) |
| @@ -9890,13 +9973,13 @@ This function might do hidden buffer changes." | |||
| 9890 | ;; | 9973 | ;; |
| 9891 | ;; | 9974 | ;; |
| 9892 | ;; | 9975 | ;; |
| 9893 | ;; The second element of the return value is non-nil when a | 9976 | ;; The second element of the return value is non-nil when something |
| 9894 | ;; `c-typedef-decl-kwds' specifier is found in the declaration. | 9977 | ;; indicating the identifier is a type occurs in the declaration. |
| 9895 | ;; Specifically it is a dotted pair (A . B) where B is t when a | 9978 | ;; Specifically it is nil, or a three element list (A B C) where C is t |
| 9896 | ;; `c-typedef-kwds' ("typedef") is present, and A is t when some | 9979 | ;; when context is '<> and the "identifier" is a found type, B is t when a |
| 9897 | ;; other `c-typedef-decl-kwds' (e.g. class, struct, enum) | 9980 | ;; `c-typedef-kwds' ("typedef") is present, and A is t when some other |
| 9898 | ;; specifier is present. I.e., (some of) the declared | 9981 | ;; `c-typedef-declkwds' (e.g. class, struct, enum) specifier is present. |
| 9899 | ;; identifier(s) are types. | 9982 | ;; I.e., (some of) the declared identifier(s) are types. |
| 9900 | ;; | 9983 | ;; |
| 9901 | ;; The third element of the return value is non-nil when the declaration | 9984 | ;; The third element of the return value is non-nil when the declaration |
| 9902 | ;; parsed might be an expression. The fourth element is the position of | 9985 | ;; parsed might be an expression. The fourth element is the position of |
| @@ -9972,6 +10055,9 @@ This function might do hidden buffer changes." | |||
| 9972 | at-type-decl | 10055 | at-type-decl |
| 9973 | ;; Set if we've a "typedef" keyword. | 10056 | ;; Set if we've a "typedef" keyword. |
| 9974 | at-typedef | 10057 | at-typedef |
| 10058 | ;; Set if `context' is '<> and the identifier is definitely a type, or | ||
| 10059 | ;; has already been recorded as a found type. | ||
| 10060 | at-<>-type | ||
| 9975 | ;; Set if we've found a specifier that can start a declaration | 10061 | ;; Set if we've found a specifier that can start a declaration |
| 9976 | ;; where there's no type. | 10062 | ;; where there's no type. |
| 9977 | maybe-typeless | 10063 | maybe-typeless |
| @@ -10050,6 +10136,11 @@ This function might do hidden buffer changes." | |||
| 10050 | (setq kwd-sym (c-keyword-sym (match-string 1))) | 10136 | (setq kwd-sym (c-keyword-sym (match-string 1))) |
| 10051 | (save-excursion | 10137 | (save-excursion |
| 10052 | (c-forward-keyword-clause 1) | 10138 | (c-forward-keyword-clause 1) |
| 10139 | (when (and (c-major-mode-is 'c++-mode) | ||
| 10140 | (c-keyword-member kwd-sym 'c-<>-sexp-kwds) | ||
| 10141 | (save-match-data | ||
| 10142 | (looking-at c-fun-name-substitute-key))) | ||
| 10143 | (c-forward-c++-requires-clause)) | ||
| 10053 | (setq kwd-clause-end (point)))) | 10144 | (setq kwd-clause-end (point)))) |
| 10054 | ((and c-opt-cpp-prefix | 10145 | ((and c-opt-cpp-prefix |
| 10055 | (looking-at c-noise-macro-with-parens-name-re)) | 10146 | (looking-at c-noise-macro-with-parens-name-re)) |
| @@ -10089,6 +10180,11 @@ This function might do hidden buffer changes." | |||
| 10089 | (point)))) | 10180 | (point)))) |
| 10090 | found-type-list)) | 10181 | found-type-list)) |
| 10091 | 10182 | ||
| 10183 | ;; Might we have a C++20 concept? i.e. template<foo bar>? | ||
| 10184 | (setq at-<>-type | ||
| 10185 | (and (eq context '<>) | ||
| 10186 | (memq found-type '(t known prefix found)))) | ||
| 10187 | |||
| 10092 | ;; Signal a type declaration for "struct foo {". | 10188 | ;; Signal a type declaration for "struct foo {". |
| 10093 | (when (and backup-at-type-decl | 10189 | (when (and backup-at-type-decl |
| 10094 | (eq (char-after) ?{)) | 10190 | (eq (char-after) ?{)) |
| @@ -10377,8 +10473,11 @@ This function might do hidden buffer changes." | |||
| 10377 | t) | 10473 | t) |
| 10378 | (when (if (save-match-data (looking-at "\\s(")) | 10474 | (when (if (save-match-data (looking-at "\\s(")) |
| 10379 | (c-safe (c-forward-sexp 1) t) | 10475 | (c-safe (c-forward-sexp 1) t) |
| 10380 | (goto-char (match-end 1)) | 10476 | (if (save-match-data |
| 10381 | t) | 10477 | (looking-at c-fun-name-substitute-key)) ; requires |
| 10478 | (c-forward-c++-requires-clause) | ||
| 10479 | (goto-char (match-end 1)) | ||
| 10480 | t)) | ||
| 10382 | (when (and (not got-suffix-after-parens) | 10481 | (when (and (not got-suffix-after-parens) |
| 10383 | (= paren-depth 0)) | 10482 | (= paren-depth 0)) |
| 10384 | (setq got-suffix-after-parens (match-beginning 0))) | 10483 | (setq got-suffix-after-parens (match-beginning 0))) |
| @@ -10971,8 +11070,8 @@ This function might do hidden buffer changes." | |||
| 10971 | (c-forward-type)))) | 11070 | (c-forward-type)))) |
| 10972 | 11071 | ||
| 10973 | (list id-start | 11072 | (list id-start |
| 10974 | (and (or at-type-decl at-typedef) | 11073 | (and (or at-type-decl at-typedef at-<>-type) |
| 10975 | (cons at-type-decl at-typedef)) | 11074 | (list at-type-decl at-typedef at-<>-type)) |
| 10976 | maybe-expression | 11075 | maybe-expression |
| 10977 | type-start | 11076 | type-start |
| 10978 | (or (eq context 'top) make-top))) | 11077 | (or (eq context 'top) make-top))) |
| @@ -12429,6 +12528,8 @@ comment at the start of cc-engine.el for more info." | |||
| 12429 | in-paren 'in-paren)) | 12528 | in-paren 'in-paren)) |
| 12430 | ((looking-at c-pre-brace-non-bracelist-key) | 12529 | ((looking-at c-pre-brace-non-bracelist-key) |
| 12431 | (setq braceassignp nil)) | 12530 | (setq braceassignp nil)) |
| 12531 | ((looking-at c-fun-name-substitute-key) | ||
| 12532 | (setq braceassignp nil)) | ||
| 12432 | ((looking-at c-return-key)) | 12533 | ((looking-at c-return-key)) |
| 12433 | ((and (looking-at c-symbol-start) | 12534 | ((and (looking-at c-symbol-start) |
| 12434 | (not (looking-at c-keywords-regexp))) | 12535 | (not (looking-at c-keywords-regexp))) |
| @@ -12439,6 +12540,11 @@ comment at the start of cc-engine.el for more info." | |||
| 12439 | (setq after-type-id-pos (point)))) | 12540 | (setq after-type-id-pos (point)))) |
| 12440 | ((eq (char-after) ?\() | 12541 | ((eq (char-after) ?\() |
| 12441 | (setq parens-before-brace t) | 12542 | (setq parens-before-brace t) |
| 12543 | ;; Have we a requires with a parenthesis list? | ||
| 12544 | (when (save-excursion | ||
| 12545 | (and (zerop (c-backward-token-2 1 nil lim)) | ||
| 12546 | (looking-at c-fun-name-substitute-key))) | ||
| 12547 | (setq braceassignp nil)) | ||
| 12442 | nil) | 12548 | nil) |
| 12443 | (t nil)) | 12549 | (t nil)) |
| 12444 | (save-excursion | 12550 | (save-excursion |
| @@ -14201,6 +14307,25 @@ comment at the start of cc-engine.el for more info." | |||
| 14201 | (goto-char placeholder) | 14307 | (goto-char placeholder) |
| 14202 | (c-add-syntax 'inher-cont (c-point 'boi))) | 14308 | (c-add-syntax 'inher-cont (c-point 'boi))) |
| 14203 | 14309 | ||
| 14310 | ;; CASE 5D.7: Continuation of a "concept foo =" line in C++20 (or | ||
| 14311 | ;; similar). | ||
| 14312 | ((and c-equals-nontype-decl-key | ||
| 14313 | (save-excursion | ||
| 14314 | (prog1 | ||
| 14315 | (and (zerop (c-backward-token-2 1 nil lim)) | ||
| 14316 | (looking-at c-operator-re) | ||
| 14317 | (equal (match-string 0) "=") | ||
| 14318 | (zerop (c-backward-token-2 1 nil lim)) | ||
| 14319 | (looking-at c-symbol-start) | ||
| 14320 | (not (looking-at c-keywords-regexp)) | ||
| 14321 | (zerop (c-backward-token-2 1 nil lim)) | ||
| 14322 | (looking-at c-equals-nontype-decl-key) | ||
| 14323 | (eq (c-beginning-of-statement-1 lim) 'same)) | ||
| 14324 | (setq placeholder (point))))) | ||
| 14325 | (goto-char placeholder) | ||
| 14326 | (c-add-stmt-syntax 'topmost-intro-cont nil nil containing-sexp | ||
| 14327 | paren-state)) | ||
| 14328 | |||
| 14204 | ;; CASE 5D.5: Continuation of the "expression part" of a | 14329 | ;; CASE 5D.5: Continuation of the "expression part" of a |
| 14205 | ;; top level construct. Or, perhaps, an unrecognized construct. | 14330 | ;; top level construct. Or, perhaps, an unrecognized construct. |
| 14206 | (t | 14331 | (t |
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index 5d80eb58e38..753ae480878 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el | |||
| @@ -887,6 +887,23 @@ casts and declarations are fontified. Used on level 2 and higher." | |||
| 887 | ,@(when (c-major-mode-is 'c++-mode) | 887 | ,@(when (c-major-mode-is 'c++-mode) |
| 888 | '(c-font-lock-c++-modules)) | 888 | '(c-font-lock-c++-modules)) |
| 889 | 889 | ||
| 890 | ;; The next regexp is highlighted with narrowing. This is so that the | ||
| 891 | ;; final "context" bit of the regexp, "\\(?:[^=]\\|$\\)", which cannot | ||
| 892 | ;; match anything non-empty at LIMIT, will match "$" instead. | ||
| 893 | ,@(when (c-lang-const c-equals-nontype-decl-kwds) | ||
| 894 | `((,(byte-compile | ||
| 895 | `(lambda (limit) | ||
| 896 | (save-restriction | ||
| 897 | (narrow-to-region (point-min) limit) | ||
| 898 | ,(c-make-font-lock-search-form | ||
| 899 | (concat (c-lang-const c-equals-nontype-decl-key) ;no \\( | ||
| 900 | (c-lang-const c-simple-ws) "+\\(" | ||
| 901 | (c-lang-const c-symbol-key) "\\)" | ||
| 902 | (c-lang-const c-simple-ws) "*" | ||
| 903 | "=\\(?:[^=]\\|$\\)") | ||
| 904 | `((,(+ 1 (c-lang-const c-simple-ws-depth)) | ||
| 905 | font-lock-type-face t))))))))) | ||
| 906 | |||
| 890 | ;; Fontify the special declarations in Objective-C. | 907 | ;; Fontify the special declarations in Objective-C. |
| 891 | ,@(when (c-major-mode-is 'objc-mode) | 908 | ,@(when (c-major-mode-is 'objc-mode) |
| 892 | `(;; Fontify class names in the beginning of message expressions. | 909 | `(;; Fontify class names in the beginning of message expressions. |
| @@ -1278,15 +1295,19 @@ casts and declarations are fontified. Used on level 2 and higher." | |||
| 1278 | (or (memq type '(c-decl-arg-start c-decl-type-start)) | 1295 | (or (memq type '(c-decl-arg-start c-decl-type-start)) |
| 1279 | (and | 1296 | (and |
| 1280 | (progn (c-backward-syntactic-ws) t) | 1297 | (progn (c-backward-syntactic-ws) t) |
| 1281 | (c-back-over-compound-identifier) | 1298 | (or |
| 1282 | (progn | 1299 | (and |
| 1283 | (c-backward-syntactic-ws) | 1300 | (c-back-over-compound-identifier) |
| 1284 | (or (bobp) | 1301 | (progn |
| 1285 | (progn | 1302 | (c-backward-syntactic-ws) |
| 1286 | (setq type (c-get-char-property (1- (point)) | 1303 | (or (bobp) |
| 1287 | 'c-type)) | 1304 | (progn |
| 1288 | (memq type '(c-decl-arg-start | 1305 | (setq type (c-get-char-property (1- (point)) |
| 1289 | c-decl-type-start)))))))))) | 1306 | 'c-type)) |
| 1307 | (memq type '(c-decl-arg-start | ||
| 1308 | c-decl-type-start)))))) | ||
| 1309 | (and (zerop (c-backward-token-2)) | ||
| 1310 | (looking-at c-fun-name-substitute-key)))))))) | ||
| 1290 | (cons 'decl nil)) | 1311 | (cons 'decl nil)) |
| 1291 | (t (cons 'arglist t))))) | 1312 | (t (cons 'arglist t))))) |
| 1292 | 1313 | ||
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index d33ed4bcda5..85f43d6a26b 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el | |||
| @@ -2593,6 +2593,35 @@ will be handled." | |||
| 2593 | t (c-make-keywords-re t (c-lang-const c-equals-type-clause-kwds))) | 2593 | t (c-make-keywords-re t (c-lang-const c-equals-type-clause-kwds))) |
| 2594 | (c-lang-defvar c-equals-type-clause-key (c-lang-const c-equals-type-clause-key)) | 2594 | (c-lang-defvar c-equals-type-clause-key (c-lang-const c-equals-type-clause-key)) |
| 2595 | 2595 | ||
| 2596 | (c-lang-defconst c-equals-nontype-decl-kwds | ||
| 2597 | "Keywords which are followed by an identifier then an \"=\" | ||
| 2598 | sign, which declares the identifier to be something other than a | ||
| 2599 | type." | ||
| 2600 | t nil | ||
| 2601 | c++ '("concept")) | ||
| 2602 | |||
| 2603 | (c-lang-defconst c-equals-nontype-decl-key | ||
| 2604 | ;; An unadorned regular expression which matches any member of | ||
| 2605 | ;; `c-equals-decl-kwds', or nil if such don't exist in the current language. | ||
| 2606 | t (when (c-lang-const c-equals-nontype-decl-kwds) | ||
| 2607 | (c-make-keywords-re nil (c-lang-const c-equals-nontype-decl-kwds)))) | ||
| 2608 | (c-lang-defvar c-equals-nontype-decl-key | ||
| 2609 | (c-lang-const c-equals-nontype-decl-key)) | ||
| 2610 | |||
| 2611 | (c-lang-defconst c-fun-name-substitute-kwds | ||
| 2612 | "Keywords which take the place of type+declarator at the beginning | ||
| 2613 | of a function-like structure, such as a C++20 \"requires\" | ||
| 2614 | clause. An arglist may or may not follow such a keyword." | ||
| 2615 | t nil | ||
| 2616 | c++ '("requires")) | ||
| 2617 | |||
| 2618 | (c-lang-defconst c-fun-name-substitute-key | ||
| 2619 | ;; An adorned regular expression which matches any member of | ||
| 2620 | ;; `c-fun-name-substitute-kwds'. | ||
| 2621 | t (c-make-keywords-re t (c-lang-const c-fun-name-substitute-kwds))) | ||
| 2622 | (c-lang-defvar c-fun-name-substitute-key | ||
| 2623 | (c-lang-const c-fun-name-substitute-key)) | ||
| 2624 | |||
| 2596 | (c-lang-defconst c-modifier-kwds | 2625 | (c-lang-defconst c-modifier-kwds |
| 2597 | "Keywords that can prefix normal declarations of identifiers | 2626 | "Keywords that can prefix normal declarations of identifiers |
| 2598 | \(and typically act as flags). Things like argument declarations | 2627 | \(and typically act as flags). Things like argument declarations |
| @@ -2938,6 +2967,17 @@ if this isn't nil." | |||
| 2938 | ;; In CORBA PSDL: | 2967 | ;; In CORBA PSDL: |
| 2939 | "ref")) | 2968 | "ref")) |
| 2940 | 2969 | ||
| 2970 | (c-lang-defconst c-pre-concept-<>-kwds | ||
| 2971 | "Keywords that may be followed by an angle bracket expression containing | ||
| 2972 | uses of \"concepts\". This is currently (2022-09) used only by C++." | ||
| 2973 | t nil | ||
| 2974 | c++ '("template")) | ||
| 2975 | |||
| 2976 | (c-lang-defconst c-pre-concept-<>-key | ||
| 2977 | ;; Regexp matching any element of `c-pre-concept-<>-kwds'. | ||
| 2978 | t (c-make-keywords-re t (c-lang-const c-pre-concept-<>-kwds))) | ||
| 2979 | (c-lang-defvar c-pre-concept-<>-key (c-lang-const c-pre-concept-<>-key)) | ||
| 2980 | |||
| 2941 | (c-lang-defconst c-<>-arglist-kwds | 2981 | (c-lang-defconst c-<>-arglist-kwds |
| 2942 | "Keywords that can be followed by a C++ style template arglist; see | 2982 | "Keywords that can be followed by a C++ style template arglist; see |
| 2943 | `c-recognize-<>-arglists' for details. That language constant is | 2983 | `c-recognize-<>-arglists' for details. That language constant is |
| @@ -3146,6 +3186,10 @@ not really template operators." | |||
| 3146 | java '("true" "false" "null") ; technically "literals", not keywords | 3186 | java '("true" "false" "null") ; technically "literals", not keywords |
| 3147 | pike '("UNDEFINED")) ;; Not a keyword, but practically works as one. | 3187 | pike '("UNDEFINED")) ;; Not a keyword, but practically works as one. |
| 3148 | 3188 | ||
| 3189 | (c-lang-defconst c-constant-key | ||
| 3190 | t (c-make-keywords-re t (c-lang-const c-constant-kwds))) | ||
| 3191 | (c-lang-defvar c-constant-key (c-lang-const c-constant-key)) | ||
| 3192 | |||
| 3149 | (c-lang-defconst c-primary-expr-kwds | 3193 | (c-lang-defconst c-primary-expr-kwds |
| 3150 | "Keywords besides constants and operators that start primary expressions." | 3194 | "Keywords besides constants and operators that start primary expressions." |
| 3151 | t nil | 3195 | t nil |
| @@ -3781,7 +3825,10 @@ is in effect when this is matched (see `c-identifier-syntax-table')." | |||
| 3781 | ;; "throw" in `c-type-modifier-kwds' is followed | 3825 | ;; "throw" in `c-type-modifier-kwds' is followed |
| 3782 | ;; by a parenthesis list, but no extra measures | 3826 | ;; by a parenthesis list, but no extra measures |
| 3783 | ;; are necessary to handle that. | 3827 | ;; are necessary to handle that. |
| 3784 | (regexp-opt (c-lang-const c-type-modifier-kwds) t) | 3828 | (regexp-opt |
| 3829 | (append (c-lang-const c-fun-name-substitute-kwds) | ||
| 3830 | (c-lang-const c-type-modifier-kwds)) | ||
| 3831 | t) | ||
| 3785 | "\\>") | 3832 | "\\>") |
| 3786 | "") | 3833 | "") |
| 3787 | "\\)") | 3834 | "\\)") |
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 15dfdc4b0e5..9dd5ddb4656 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el | |||
| @@ -2403,7 +2403,7 @@ with // and /*, not more generic line and block comments." | |||
| 2403 | (setq pseudo (c-cheap-inside-bracelist-p (c-parse-state))))))) | 2403 | (setq pseudo (c-cheap-inside-bracelist-p (c-parse-state))))))) |
| 2404 | (goto-char pseudo)) | 2404 | (goto-char pseudo)) |
| 2405 | t) | 2405 | t) |
| 2406 | (> (point) bod-lim) | 2406 | (>= (point) bod-lim) |
| 2407 | (progn (c-forward-syntactic-ws) | 2407 | (progn (c-forward-syntactic-ws) |
| 2408 | ;; Have we got stuck in a comment at EOB? | 2408 | ;; Have we got stuck in a comment at EOB? |
| 2409 | (not (and (eobp) | 2409 | (not (and (eobp) |
| @@ -2427,7 +2427,8 @@ with // and /*, not more generic line and block comments." | |||
| 2427 | (and (> (point) bod-lim) | 2427 | (and (> (point) bod-lim) |
| 2428 | (or (memq (char-before) '(?\( ?\[)) | 2428 | (or (memq (char-before) '(?\( ?\[)) |
| 2429 | (and (eq (char-before) ?\<) | 2429 | (and (eq (char-before) ?\<) |
| 2430 | (eq (c-get-char-property | 2430 | (equal |
| 2431 | (c-get-char-property | ||
| 2431 | (1- (point)) 'syntax-table) | 2432 | (1- (point)) 'syntax-table) |
| 2432 | c-<-as-paren-syntax)) | 2433 | c-<-as-paren-syntax)) |
| 2433 | (and (eq (char-before) ?{) | 2434 | (and (eq (char-before) ?{) |