tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, rsmith, rjmccall.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Sorry for the title, I'm not 100% sure that's even correct here.

This call to `ProhibitAttributes()` is dead code in the case of GNU-style 
attributes. They are needed in e.g. 
`clang/test/Parser/objcbridge-related-attribute.m`.

However, adding a `&& !getLangOpts().ObjC` to the if statement just before is 
also not sufficient since clang expects to parse GNU-style attributes at this 
place without diagnosing them as well, for example in 
`clang/test/Sema/struct-decl.c:71`. This ends up diagnosing the wrongly-placed 
`noreturn` attribute at a later stage.

Once `ProhibitAttributes()` works with GNU-style attributes the cases mentioned 
above (and tons of other cases) are being diagnosed as incorrect.

This change depends on https://reviews.llvm.org/D97362 landing first.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99278

Files:
  clang/lib/Parse/ParseDeclCXX.cpp


Index: clang/lib/Parse/ParseDeclCXX.cpp
===================================================================
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1933,7 +1933,7 @@
                                TemplateParams ? TemplateParams->size() : 0));
   } else {
     if (TUK != Sema::TUK_Declaration && TUK != Sema::TUK_Definition)
-      ProhibitAttributes(attrs);
+      ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed, /* 
DiagnoseEmptyAttrs=*/true);
 
     if (TUK == Sema::TUK_Definition &&
         TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {


Index: clang/lib/Parse/ParseDeclCXX.cpp
===================================================================
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1933,7 +1933,7 @@
                                TemplateParams ? TemplateParams->size() : 0));
   } else {
     if (TUK != Sema::TUK_Declaration && TUK != Sema::TUK_Definition)
-      ProhibitAttributes(attrs);
+      ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed, /* DiagnoseEmptyAttrs=*/true);
 
     if (TUK == Sema::TUK_Definition &&
         TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to