diff --git a/CHANGES.md b/CHANGES.md index 37ed72ec07..5ba52340f4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -60,6 +60,7 @@ Core Grammars: - fix(yaml) - Fixed wrong escaping behavior in single quoted strings [guuido] - enh(nim) - Add `concept` and `defer` to list of Nim keywords [Jake Leahy] - fix(cpp) - Exclude keywords from highlighting as function calls [Eisenwave] +- enh(cpp) add C++26 keywords, `#embed`, and compiler-builtin types [Eisenwave] New Grammars: diff --git a/src/languages/cpp.js b/src/languages/cpp.js index 1b3e337784..94e83a9554 100644 --- a/src/languages/cpp.js +++ b/src/languages/cpp.js @@ -99,7 +99,7 @@ export default function(hljs) { begin: /#\s*[a-z]+\b/, end: /$/, keywords: { keyword: - 'if else elif endif define undef warning error line ' + 'if else elif embed endif define undef warning error line ' + 'pragma _Pragma ifdef ifndef include' }, contains: [ { @@ -151,6 +151,7 @@ export default function(hljs) { 'constexpr', 'constinit', 'continue', + 'contract_assert', 'decltype', 'default', 'delete', @@ -181,8 +182,10 @@ export default function(hljs) { 'or', 'or_eq', 'override', + 'pre', 'private', 'protected', + 'post', 'public', 'reflexpr', 'register', @@ -212,7 +215,9 @@ export default function(hljs) { 'volatile', 'while', 'xor', - 'xor_eq' + 'xor_eq', + '_Atomic', + '_BitInt' ]; // https://en.cppreference.com/w/cpp/keyword diff --git a/test/markup/cpp/function-declarations.expect.txt b/test/markup/cpp/function-declarations.expect.txt index 5279754667..dea41bf652 100644 --- a/test/markup/cpp/function-declarations.expect.txt +++ b/test/markup/cpp/function-declarations.expect.txt @@ -23,3 +23,7 @@ explicit A(): a(10) {} extern void f(int), g(char); + +void throwing(int x) noexcept(false); +void deleted() = delete("reason"); +void contracts(int x) pre(x > 10) post(r : r != 0); diff --git a/test/markup/cpp/function-declarations.txt b/test/markup/cpp/function-declarations.txt index c78ffc21a7..ec287a9722 100644 --- a/test/markup/cpp/function-declarations.txt +++ b/test/markup/cpp/function-declarations.txt @@ -23,3 +23,7 @@ void A(): a(10) {} explicit A(): a(10) {} extern void f(int), g(char); + +void throwing(int x) noexcept(false); +void deleted() = delete("reason"); +void contracts(int x) pre(x > 10) post(r : r != 0); diff --git a/test/markup/cpp/function-like-keywords.expect.txt b/test/markup/cpp/function-like-keywords.expect.txt index 2f6e266e58..9f34c0be0d 100644 --- a/test/markup/cpp/function-like-keywords.expect.txt +++ b/test/markup/cpp/function-like-keywords.expect.txt @@ -7,6 +7,8 @@ for (;;) {} -void f() = delete("reason"); - static_assert(true); +contract_assert(false); + +_BitInt(64) x; +_Atomic(int) y; diff --git a/test/markup/cpp/function-like-keywords.txt b/test/markup/cpp/function-like-keywords.txt index 608611fa8d..8a8e79fd22 100644 --- a/test/markup/cpp/function-like-keywords.txt +++ b/test/markup/cpp/function-like-keywords.txt @@ -7,6 +7,8 @@ while (ch) {} for (;;) {} -void f() = delete("reason"); - static_assert(true); +contract_assert(false); + +_BitInt(64) x; +_Atomic(int) y;