Subject: CC Mode 5.35.1 (C++//l); Highlight for C++20 keywords
From: Zhiwei Chen <[email-masked]>
To: [email-masked]
Date: Sun, 03 Jul 2022 03:12:28 +0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Package: cc-mode

See the comments.

#+begin_src C++
#if __has_include(<bits/stdc++.h>)
#include <bits/stdc++.h>
#endif

#include <cstdint>
#include <concepts>

// no highlight for consteval keyword
consteval int sqr(int x) {
    return x * x;
}

// no highlight for constinit keyword
constinit int four = sqr(16);

class Foo {
public:
    // <=> highlights wrong
    auto operator<=>(const Foo&) const = default;

private:
    // no highlight for alignas keyword
    alignas(alignof(std::uint64_t)) int val_;
};

template <typename T>
requires std::integral<T> // 'requires' occasionally has a font-lock-type-face
T add(T a, T b) {
    return a + b;
}

int main() {
    const char8_t c1 = 0; // char8_t is missing in `c-primitive-type-kwds'. cc-langs.el L2205

    return 0;
}
#+end_src

Emacs  : GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo version 1.17.6)
 of 2022-07-02
Package: CC Mode 5.35.1 (C++//l)
Buffer Style: gnu
c-emacs-features: (pps-extended-state col-0-paren posix-char-classes gen-string-delim gen-comment-delim syntax-properties 1-bit)

current state:
==============
(setq
 c-basic-offset 4
 c-comment-only-line-offset '(0 . 0)
 c-indent-comment-alist '((anchored-comment column . 0) (end-block space . 1)
                          (cpp-end-block space . 2))
 c-indent-comments-syntactically-p nil
 c-block-comment-prefix ""
 c-comment-prefix-regexp '((c-mode . "//+!?\\|\\**") (c++-mode . "//+!?\\|\\**")
                           (awk-mode . "#+") (other . "//+\\|\\**"))
 c-doc-comment-style '((c-mode . gtkdoc) (c++-mode . doxygen))
 c-cleanup-list '(scope-operator)
 c-hanging-braces-alist '((substatement-open before after) (arglist-cont-nonempty))
 c-hanging-colons-alist nil
 c-hanging-semi&comma-criteria '(c-semi&comma-inside-parenlist)
 c-backslash-column 48
 c-backslash-max-column 72
 c-special-indent-hook '(t c-gnu-impose-minimum)
 c-label-minimum-indentation 0
 c-offsets-alist '((inexpr-class . +)
                   (incomposition . +)
                   (inmodule . +)
                   (composition-close . 0)
                   (module-close . 0)
                   (composition-open . 0)
                   (module-open . 0)
                   (objc-method-call-cont
                    c-lineup-ObjC-method-call-colons
                    c-lineup-ObjC-method-call
                    +
                    )
                   (objc-method-args-cont . c-lineup-ObjC-method-args)
                   (objc-method-intro . [0])
                   (cpp-define-intro c-lineup-cpp-define +)
                   (annotation-var-cont . +)
                   (annotation-top-cont . 0)
                   (knr-argdecl . 0)
                   (knr-argdecl-intro . 5)
                   (c . c-lineup-C-comments)
                   (string . c-lineup-dont-change)
                   (defun-open . 0)
                   (defun-close . 0)
                   (defun-block-intro . +)
                   (class-open . 0)
                   (class-close . 0)
                   (access-label . -)
                   (inline-open . 0)
                   (inline-close . 0)
                   (inclass . +)
                   (friend . 0)
                   (func-decl-cont . +)
                   (brace-list-open . 0)
                   (brace-list-close . 0)
                   (brace-list-intro . +)
                   (brace-list-entry . 0)
                   (brace-entry-open . 0)
                   (namespace-open . 0)
                   (namespace-close . 0)
                   (innamespace . 0)
                   (block-open . 0)
                   (block-close . 0)
                   (topmost-intro . 0)
                   (topmost-intro-cont . c-lineup-topmost-intro-cont)
                   (member-init-intro . +)
                   (member-init-cont . c-lineup-multi-inher)
                   (inher-intro . +)
                   (inher-cont . c-lineup-multi-inher)
                   (statement . 0)
                   (statement-cont c-lineup-ternary-bodies +)
                   (statement-block-intro . +)
                   (statement-case-intro . +)
                   (statement-case-open . +)
                   (substatement . +)
                   (substatement-open . 0)
                   (substatement-label . 0)
                   (case-label . 0)
                   (label . 0)
                   (do-while-closure . 0)
                   (else-clause . 0)
                   (catch-clause . 0)
                   (comment-intro . c-lineup-comment)
                   (arglist-intro . +)
                   (arglist-cont . 0)
                   (arglist-cont-nonempty . c-lineup-arglist)
                   (arglist-close . c-lineup-close-paren)
                   (stream-op . c-lineup-streamop)
                   (cpp-macro . -1000)
                   (cpp-macro-cont . +)
                   (extern-lang-open . 0)
                   (extern-lang-close . 0)
                   (inextern-lang . 0)
                   (inlambda . 0)
                   (lambda-intro-cont . +)
                   (inexpr-statement . 0)
                   (template-args-cont c-lineup-template-args +)
                   )
 c-buffer-is-cc-mode 'c++-mode
 c-tab-always-indent t
 c-syntactic-indentation t
 c-syntactic-indentation-in-macros t
 c-ignore-auto-fill '(string cpp code)
 c-auto-align-backslashes t
 c-backspace-function 'backward-delete-char-untabify
 c-delete-function 'delete-char
 c-electric-pound-behavior nil
 c-default-style '((java-mode . "java") (awk-mode . "awk") (other . "gnu"))
 c-enable-xemacs-performance-kludge-p nil
 c-old-style-variable-behavior nil
 defun-prompt-regexp nil
 tab-width 4
 comment-column 32
 parse-sexp-ignore-comments t
 parse-sexp-lookup-properties t
 auto-fill-function nil
 comment-multi-line t
 comment-start-skip "\\(?://+\\|/\\*+\\)\\s *"
 fill-prefix nil
 fill-column 80
 paragraph-start "[ 	]*\\(//+!?\\|\\**\\)[ 	]*$\\|^\f"
 adaptive-fill-mode t
 adaptive-fill-regexp "[ 	]*\\(//+!?\\|\\**\\)[ 	]*\\([ 	]*\\([-–!|#%;>*·•‣⁃◦]+[ 	]*\\)*\\)"
 )
-- 
Zhiwei Chen