From d6587c54887d8be38ae0126ca831d3738fd90501 Mon Sep 17 00:00:00 2001 From: James Buren Date: Thu, 7 Nov 2024 14:28:47 -0600 Subject: [PATCH] [C] Add support for alignas and its aliases This was first added in C11 but has since been revised by C23. It functions like typeof but modifies the alignment of the type or variable instead of being a type itself. --- C++/C.sublime-syntax | 4 ++-- C++/syntax_test_c.c | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index 5c65a3fd0e..8d649e33e7 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -52,7 +52,7 @@ variables: type_qualifier: 'const|volatile|_Atomic' compiler_directive: 'inline|restrict|__restrict__|__restrict|_Noreturn|noreturn' modifiers: '{{storage_classes}}|{{type_qualifier}}|{{compiler_directive}}' - non_func_keywords: 'if|for|switch|while|decltype|typeof|typeof_unqual|_Atomic|_BitInt|sizeof|alignof|_Alignof|static_assert|_Static_assert|__declspec|__attribute__' + non_func_keywords: 'if|for|switch|while|decltype|typeof|typeof_unqual|_Atomic|_BitInt|sizeof|alignof|_Alignof|alignas|_Alignas|static_assert|_Static_assert|__declspec|__attribute__' contexts: main: @@ -263,7 +263,7 @@ contexts: - include: types-parens types-parens: - - match: '\b(typeof|__typeof|__typeof__|typeof_unqual|_Atomic|_BitInt)\b\s*(\()' + - match: '\b(typeof|__typeof|__typeof__|typeof_unqual|alignas|_Alignas|_Atomic|_BitInt)\b\s*(\()' captures: 1: keyword.declaration.type.c 2: meta.group.c punctuation.section.group.begin.c diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index 060bf4d50c..b10542dc18 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -215,6 +215,12 @@ _Atomic int ai1; _Atomic(int) ai2; /* <- storage.modifier */ +_Alignas(int) int aa1; +/* <- keyword.declaration.type */ + +alignas(int) int aa2; +/* <- keyword.declaration.type */ + thread_local int tl1; /* <- storage.modifier */