1 // RUN: %clang_cc1 -DNO_DTORS -fno-c++-static-destructors -verify %s
2 // RUN: %clang_cc1 -verify %s
4 struct SecretDestructor {
6 // expected-note@+2 4 {{private}}
8 private: ~SecretDestructor(); // expected-note 2 {{private}}
12 thread_local SecretDestructor sd2;
14 static SecretDestructor sd3;
15 thread_local SecretDestructor sd4;
19 // SecretDestructor sd1; // expected-error@-8 {{private}}
20 // thread_local SecretDestructor sd2; // expected-error@-8 {{private}}
22 // static SecretDestructor sd3; // expected-error@-8 {{private}}
23 // thread_local SecretDestructor sd4; // expected-error@-8 {{private}}
27 [[clang::always_destroy]] SecretDestructor sd6; // expected-error{{private}}
28 [[clang::always_destroy]] thread_local SecretDestructor sd7; // expected-error{{private}}
30 [[clang::no_destroy]] SecretDestructor sd8;
33 [[clang::no_destroy]] int p; // expected-error{{no_destroy attribute can only be applied to a variable with static or thread storage duration}}
34 [[clang::always_destroy]] int p2; // expected-error{{always_destroy attribute can only be applied to a variable with static or thread storage duration}}
35 [[clang::no_destroy]] static int p3;
36 [[clang::always_destroy]] static int p4;
39 [[clang::always_destroy]] [[clang::no_destroy]] int p; // expected-error{{'no_destroy' and 'always_destroy' attributes are not compatible}} // expected-note{{here}}
40 [[clang::no_destroy]] [[clang::always_destroy]] int p2; // expected-error{{'always_destroy' and 'no_destroy' attributes are not compatible}} // expected-note{{here}}
42 [[clang::always_destroy]] void f() {} // expected-warning{{'always_destroy' attribute only applies to variables}}
43 struct [[clang::no_destroy]] DoesntApply {}; // expected-warning{{'no_destroy' attribute only applies to variables}}
45 [[clang::no_destroy(0)]] int no_args; // expected-error{{'no_destroy' attribute takes no arguments}}
46 [[clang::always_destroy(0)]] int no_args2; // expected-error{{'always_destroy' attribute takes no arguments}}