tbaeder created this revision. tbaeder added reviewers: aaron.ballman, rsmith. tbaeder requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
We are parsing both C++11 and GNU-style attributes here, but the previous `ProhibitAttributes()` call was never working for GNU-style attributes. GNU-style attributes are however expected to be parsed and not diagnosed, for example in `clang/test/Sema/ast-print` in the following code: // CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes2 *EnumWithAttributes2Ptr; // expected-warning@+2 {{'EnumWithAttributes2' is deprecated}} // expected-note@+1 {{'EnumWithAttributes2' has been explicitly marked deprecated here}} enum __attribute__((deprecated)) EnumWithAttributes2 *EnumWithAttributes2Ptr; This is essentially the same as https://reviews.llvm.org/D99278 and needs https://reviews.llvm.org/D97362 to be applied first. The comment just above this change is a bit confusing since it tries to explain that "an elaborated-type-specifier has a much more constrained grammar", but does not mention any attributes. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D99338 Files: clang/lib/Parse/ParseDecl.cpp Index: clang/lib/Parse/ParseDecl.cpp =================================================================== --- clang/lib/Parse/ParseDecl.cpp +++ clang/lib/Parse/ParseDecl.cpp @@ -4653,7 +4653,7 @@ // or opaque-enum-declaration anywhere. if (IsElaboratedTypeSpecifier && !getLangOpts().MicrosoftExt && !getLangOpts().ObjC) { - ProhibitAttributes(attrs); + ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed, /*DiagnoseEmptyAttrs=*/true); if (BaseType.isUsable()) Diag(BaseRange.getBegin(), diag::ext_enum_base_in_type_specifier) << (AllowEnumSpecifier == AllowDefiningTypeSpec::Yes) << BaseRange;
Index: clang/lib/Parse/ParseDecl.cpp =================================================================== --- clang/lib/Parse/ParseDecl.cpp +++ clang/lib/Parse/ParseDecl.cpp @@ -4653,7 +4653,7 @@ // or opaque-enum-declaration anywhere. if (IsElaboratedTypeSpecifier && !getLangOpts().MicrosoftExt && !getLangOpts().ObjC) { - ProhibitAttributes(attrs); + ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed, /*DiagnoseEmptyAttrs=*/true); if (BaseType.isUsable()) Diag(BaseRange.getBegin(), diag::ext_enum_base_in_type_specifier) << (AllowEnumSpecifier == AllowDefiningTypeSpec::Yes) << BaseRange;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits