[clang] [CLANG] Enable alignas after GNU attributes (PR #133107)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 15 09:20:17 PDT 2025


================
@@ -2,3 +2,26 @@
 
 _Alignas(int) struct c1; // expected-warning {{'_Alignas' attribute ignored}}
 alignas(int) struct c1; // expected-warning {{'alignas' attribute ignored}}
+
+
+__attribute__(()) [[]] alignas(int) int a; // expected-none TODO: actually this line should be an error
+__attribute__(()) alignas(int) [[]] int b; // expected-error {{an attribute list cannot appear here}}
+__attribute__(()) alignas(int) int c; // expected-none
+[[]] __attribute__(()) alignas(int) int d; // expected-none
+alignas(int) [[]] __attribute__(()) int e; // expected-error {{an attribute list cannot appear here}}
+
+struct C1 {
+    __attribute__(()) [[]] alignas(int) int a; // expected-error {{an attribute list cannot appear here}}
+    __attribute__(()) alignas(int) [[]] int b; // expected-error {{an attribute list cannot appear here}}
+    __attribute__(()) alignas(int) int c; // expected-none
+    [[]] __attribute__(()) alignas(int) int d; // expected-none
+    alignas(int) [[]] __attribute__(()) int e; // expected-error {{an attribute list cannot appear here}}
+};
+
+void fn_with_decl() {
+    __attribute__(()) [[]] alignas(int) int a; // expected-error {{an attribute list cannot appear here}}
+    __attribute__(()) alignas(int) [[]] int b; // expected-error {{an attribute list cannot appear here}}
+    __attribute__(()) alignas(int) int c; // expected-none
+    [[]] __attribute__(()) alignas(int) int d; // expected-none
+    alignas(int) [[]] __attribute__(()) int e; // expected-error {{an attribute list cannot appear here}}
+}
----------------
AaronBallman wrote:

Can you add a newline to the end of the file?

https://github.com/llvm/llvm-project/pull/133107


More information about the cfe-commits mailing list