[clang] [C++] Fix parsing of _Alignas in local declarations (PR #81915)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 15 12:38:24 PST 2024


================
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify=expected,cpp
+// RUN: %clang_cc1 -x c %s -fsyntax-only -verify=expected,c
+
+// Ensure that we correctly parse _Alignas as an extension in C++.
+_Alignas(64) int i1;
+_Alignas(long long) int i2;
+int volatile _Alignas(64) i3; // Test strange ordering
+
+void foo(void) {
+  // We previously rejected these valid declarations.
+  _Alignas(8) char i4;
+  _Alignas(char) char i5;
+
+  (void)(int _Alignas(64))0; // expected-warning {{'_Alignas' attribute ignored when parsing type}}
+  // FIXME: C and C++ should both diagnose the same way, as being ignored.
----------------
AaronBallman wrote:

Note: I plan to fix this in a follow-up

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


More information about the cfe-commits mailing list