[clang] [clang] Improve `_Alignas` on a `struct` declaration diagnostic (PR #65638)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 16 11:06:12 PDT 2023


================
@@ -186,14 +186,14 @@ class AttributeCommonInfo {
   bool isGNUScope() const;
   bool isClangScope() const;
 
-  bool isCXX11Attribute() const { return SyntaxUsed == AS_CXX11 || IsAlignas; }
-
+  bool isAlignas() const { return IsAlignas; }
+  bool isCXX11Attribute() const { return SyntaxUsed == AS_CXX11; }
----------------
AaronBallman wrote:

I think the trouble is that we've got code like this: https://github.com/llvm/llvm-project/blob/eb14f47bf1ccfda500ba3c3092d70e269f6f0b56/clang/lib/Parse/ParseDeclCXX.cpp#L3062 where we're using "isCXX11Attribute()" to mean "attribute-specifier" as a grammar term and not `[[]]` syntax specifically.

As best I can tell, I think we're fine for `isAlignas()` to report true for both `alignas` and `_Alignas` spellings; we can distinguish between the C and C++ spellings by looking at the language options in force. WDYT @erichkeane?

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


More information about the cfe-commits mailing list