]> git.eshelyaron.com Git - emacs.git/commitdiff
CC Mode: A new operator and some new keywords for C++20
authorAlan Mackenzie <acm@muc.de>
Tue, 4 Oct 2022 17:13:56 +0000 (17:13 +0000)
committerAlan Mackenzie <acm@muc.de>
Tue, 4 Oct 2022 17:19:33 +0000 (17:19 +0000)
* lisp/progmodes/cc-langs.el (c-operators, c-overloadable-operators)
(c-arithmetic-operators): Add the "spaceship" operator for C++.
(c-primitive-type-kwds): Add char8_t for C++.
(c-decl-hangon-kwds, c-paren-nontype-kwds): Add alignas for C++.

lisp/progmodes/cc-langs.el

index 3b008fd6dc7d4da613a06c5b5b505e38f6a0cb81..cd23483a58fce2ce20fb0325e4319ca8ebbe3506 100644 (file)
@@ -1330,6 +1330,10 @@ since CC Mode treats every identifier as an expression."
                  ,@(when (c-major-mode-is 'java-mode)
                      '(">>>")))
 
+      ;; The C++ "spaceship" operator.
+      ,@(when (c-major-mode-is 'c++-mode)
+         `((left-assoc "<=>")))
+
       ;; Relational.
       (left-assoc "<" ">" "<=" ">="
                  ,@(when (c-major-mode-is 'java-mode)
@@ -1443,7 +1447,7 @@ form\".  See also `c-op-identifier-prefix'."
         "^" "??'" "xor" "&" "bitand" "|" "??!" "bitor" "~" "??-" "compl"
         "!" "=" "<" ">" "+=" "-=" "*=" "/=" "%=" "^="
         "??'=" "xor_eq" "&=" "and_eq" "|=" "??!=" "or_eq"
-        "<<" ">>" ">>=" "<<=" "==" "!=" "not_eq" "<=" ">="
+        "<<" ">>" ">>=" "<<=" "==" "!=" "not_eq" "<=>" "<=" ">="
         "&&" "and" "||" "??!??!" "or" "++" "--" "," "->*" "->"
         "()" "[]" "<::>" "??(??)")
   ;; These work like identifiers in Pike.
@@ -1565,8 +1569,10 @@ operators."
   "List of all arithmetic operators, including \"+=\", etc."
   ;; Note: in the following, there are too many operators for AWK and IDL.
   t (append (c-lang-const c-assignment-operators)
-           '("+" "-" "*" "/" "%"
+           `("+" "-" "*" "/" "%"
              "<<" ">>"
+             ,@(if (c-major-mode-is 'c++-mode)
+                   '("<=>"))
              "<" ">" "<=" ">="
              "==" "!="
              "&" "^" "|"
@@ -2216,7 +2222,7 @@ the appropriate place for that."
        '("_Bool" "_Complex" "_Imaginary") ; Conditionally defined in C99.
        (c-lang-const c-primitive-type-kwds))
   c++  (append
-       '("bool" "wchar_t" "char16_t" "char32_t")
+       '("bool" "wchar_t" "char8_t" "char16_t" "char32_t")
        (c-lang-const c-primitive-type-kwds))
   ;; Objective-C extends C, but probably not the new stuff in C99.
   objc (append
@@ -2713,7 +2719,8 @@ one of `c-type-list-kwds', `c-ref-list-kwds',
   (c c++) '(;; GCC extension.
            "__attribute__"
            ;; MSVC extension.
-           "__declspec"))
+           "__declspec")
+  c++ (append (c-lang-const c-decl-hangon-kwds) '("alignas")))
 
 (c-lang-defconst c-decl-hangon-key
   ;; Adorned regexp matching `c-decl-hangon-kwds'.
@@ -2937,7 +2944,7 @@ contain type identifiers."
            "__attribute__"
            ;; MSVC extension.
            "__declspec")
-  c++ (append (c-lang-const c-paren-nontype-kwds) '("noexcept")))
+  c++ (append (c-lang-const c-paren-nontype-kwds) '("noexcept" "alignas")))
 
 (c-lang-defconst c-paren-nontype-key
   t (c-make-keywords-re t (c-lang-const c-paren-nontype-kwds)))