Author: epilk Date: Tue Aug 21 10:50:10 2018 New Revision: 340311 URL: http://llvm.org/viewvc/llvm-project?rev=340311&view=rev Log: Address Aaron Ballman's post-commit review comments from r340306, NFC
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/test/SemaCXX/no_destroy.cpp Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=340311&r1=340310&r2=340311&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Aug 21 10:50:10 2018 @@ -5918,17 +5918,16 @@ static void handleOpenCLAccessAttr(Sema } 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); - } } //===----------------------------------------------------------------------===// Modified: cfe/trunk/test/SemaCXX/no_destroy.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/no_destroy.cpp?rev=340311&r1=340310&r2=340311&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/no_destroy.cpp (original) +++ cfe/trunk/test/SemaCXX/no_destroy.cpp Tue Aug 21 10:50:10 2018 @@ -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}} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits