}
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);
- }
}
//===----------------------------------------------------------------------===//
[[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}}