From: Erik Pilkington Date: Tue, 21 Aug 2018 17:50:10 +0000 (+0000) Subject: Address Aaron Ballman's post-commit review comments from r340306, NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=446ad5873657e07917ecf631dd778863d27eb122;p=clang Address Aaron Ballman's post-commit review comments from r340306, NFC git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340311 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 27eb533360..d72b8fbb1a 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -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(D) || !cast(D)->hasGlobalStorage()) { + if (!cast(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(S, D, A); - } else { + else handleSimpleAttributeWithExclusions(S, D, A); - } } //===----------------------------------------------------------------------===// diff --git a/test/SemaCXX/no_destroy.cpp b/test/SemaCXX/no_destroy.cpp index bdb8077cb5..7afbf99982 100644 --- a/test/SemaCXX/no_destroy.cpp +++ b/test/SemaCXX/no_destroy.cpp @@ -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}}