blob: bdb8077cb580ea7f9873710b18b654c2df56c624 [file] [log] [blame]
Erik Pilkington5a559e62018-08-21 17:24:06 +00001// RUN: %clang_cc1 -DNO_DTORS -fno-c++-static-destructors -verify %s
2// RUN: %clang_cc1 -verify %s
3
4struct SecretDestructor {
5#ifndef NO_DTORS
6 // expected-note@+2 4 {{private}}
7#endif
8private: ~SecretDestructor(); // expected-note 2 {{private}}
9};
10
11SecretDestructor sd1;
12thread_local SecretDestructor sd2;
13void locals() {
14 static SecretDestructor sd3;
15 thread_local SecretDestructor sd4;
16}
17
18#ifndef NO_DTORS
19// SecretDestructor sd1; // expected-error@-8 {{private}}
20// thread_local SecretDestructor sd2; // expected-error@-8 {{private}}
21// void locals() {
22// static SecretDestructor sd3; // expected-error@-8 {{private}}
23// thread_local SecretDestructor sd4; // expected-error@-8 {{private}}
24// }
25#endif
26
27[[clang::always_destroy]] SecretDestructor sd6; // expected-error{{private}}
28[[clang::always_destroy]] thread_local SecretDestructor sd7; // expected-error{{private}}
29
30[[clang::no_destroy]] SecretDestructor sd8;
31
32int main() {
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;
37}
38
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}}