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

Jerin Philip via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 20 11:01:21 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; }
   bool isC23Attribute() const { return SyntaxUsed == AS_C23; }
 
   /// The attribute is spelled [[]] in either C or C++ mode, including standard
   /// attributes spelled with a keyword, like alignas.
   bool isStandardAttributeSyntax() const {
-    return isCXX11Attribute() || isC23Attribute();
+    return isCXX11Attribute() || isC23Attribute() || IsAlignas;
----------------
jerinphilip wrote:

I've mentioned on discord this already, adding here to keep discussions consolidated. 

_Standard Attributes_ appear to be defined and documented in [C++](https://en.cppreference.com/w/cpp/language/attributes#Standard_attributes) and [C](https://en.cppreference.com/w/cpp/language/attributes#Standard_attributes) (See also [draft](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf), Page 141) as something different than the intended usage here making the clang terminology (`isStandardAttributeSyntax`) confusing. I realize I may be being pedantic about _naming this properly_, but I figure adding more information here should help synchronize and connect the implementation to the spec to take discussion forward. 

I'm not sure what this function intends at this stage, but I'm guessing a sane choice is `isCXX11AttributeSpecifier() || isC23AttributeSpecifier()`, including `_Alignas`. 

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


More information about the cfe-commits mailing list