]> granicus.if.org Git - clang/commitdiff
Address Aaron Ballman's post-commit review comments from r340306, NFC
authorErik Pilkington <erik.pilkington@gmail.com>
Tue, 21 Aug 2018 17:50:10 +0000 (17:50 +0000)
committerErik Pilkington <erik.pilkington@gmail.com>
Tue, 21 Aug 2018 17:50:10 +0000 (17:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340311 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclAttr.cpp
test/SemaCXX/no_destroy.cpp

index 27eb533360cc7d76287e60c8b0222fbf940843af..d72b8fbb1aaca662f9d5f23b73b729f30a91995c 100644 (file)
@@ -5918,17 +5918,16 @@ static void handleOpenCLAccessAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
 }
 
 static void handleDestroyAttr(Sema &S, Decl *D, const ParsedAttr &A) {
-  if (!isa<VarDecl>(D) || !cast<VarDecl>(D)->hasGlobalStorage()) {
+  if (!cast<VarDecl>(D)->hasGlobalStorage()) {
     S.Diag(D->getLocation(), diag::err_destroy_attr_on_non_static_var)
         << (A.getKind() == ParsedAttr::AT_AlwaysDestroy);
     return;
   }
 
-  if (A.getKind() == ParsedAttr::AT_AlwaysDestroy) {
+  if (A.getKind() == ParsedAttr::AT_AlwaysDestroy)
     handleSimpleAttributeWithExclusions<AlwaysDestroyAttr, NoDestroyAttr>(S, D, A);
-  } else {
+  else
     handleSimpleAttributeWithExclusions<NoDestroyAttr, AlwaysDestroyAttr>(S, D, A);
-  }
 }
 
 //===----------------------------------------------------------------------===//
index bdb8077cb580ea7f9873710b18b654c2df56c624..7afbf999825308618e492fffeda9d8984e87b96f 100644 (file)
@@ -38,3 +38,9 @@ int main() {
 
 [[clang::always_destroy]] [[clang::no_destroy]] int p; // expected-error{{'no_destroy' and 'always_destroy' attributes are not compatible}} // expected-note{{here}}
 [[clang::no_destroy]] [[clang::always_destroy]] int p2; // expected-error{{'always_destroy' and 'no_destroy' attributes are not compatible}} // expected-note{{here}}
+
+[[clang::always_destroy]] void f() {} // expected-warning{{'always_destroy' attribute only applies to variables}}
+struct [[clang::no_destroy]] DoesntApply {};  // expected-warning{{'no_destroy' attribute only applies to variables}}
+
+[[clang::no_destroy(0)]] int no_args; // expected-error{{'no_destroy' attribute takes no arguments}}
+[[clang::always_destroy(0)]] int no_args2; // expected-error{{'always_destroy' attribute takes no arguments}}