Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Sema / attr-loader-uninitialized.cpp
blob61ff36983a44a7e0268c7af911b3247335cb05b7
1 // RUN: %clang_cc1 %s -verify -fsyntax-only
3 int good __attribute__((loader_uninitialized));
4 static int local_ok __attribute__((loader_uninitialized));
5 int hidden_ok __attribute__((visibility("hidden"))) __attribute__((loader_uninitialized));
7 const int still_cant_be_const __attribute__((loader_uninitialized));
8 extern int external_rejected __attribute__((loader_uninitialized));
9 // expected-error@-1 {{variable 'external_rejected' cannot be declared both 'extern' and with the 'loader_uninitialized' attribute}}
11 struct S;
12 extern S incomplete_external_rejected __attribute__((loader_uninitialized));
13 // expected-error@-1 {{variable 'incomplete_external_rejected' cannot be declared both 'extern' and with the 'loader_uninitialized' attribute}}
15 int noargs __attribute__((loader_uninitialized(0)));
16 // expected-error@-1 {{'loader_uninitialized' attribute takes no arguments}}
18 int init_rejected __attribute__((loader_uninitialized)) = 42;
19 // expected-error@-1 {{variable with 'loader_uninitialized' attribute cannot have an initializer}}
21 void func() __attribute__((loader_uninitialized))
22 // expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}}
24 int local __attribute__((loader_uninitialized));
25 // expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}}
27 static int sl __attribute__((loader_uninitialized));
30 struct s {
31 __attribute__((loader_uninitialized)) int field;
32 // expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}}
34 static __attribute__((loader_uninitialized)) int sfield;
36 } __attribute__((loader_uninitialized));
37 // expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}}
39 int redef_attr_first __attribute__((loader_uninitialized));
40 int redef_attr_first;
41 // expected-error@-1 {{redefinition of 'redef_attr_first'}}
42 // expected-note@-3 {{previous definition is here}}
44 int redef_attr_second;
45 int redef_attr_second __attribute__((loader_uninitialized));
46 // expected-warning@-1 {{attribute declaration must precede definition}}
47 // expected-note@-3 {{previous definition is here}}
48 // expected-error@-3 {{redefinition of 'redef_attr_second'}}
49 // expected-note@-5 {{previous definition is here}}
51 struct trivial {};
53 trivial default_ok __attribute__((loader_uninitialized));
54 trivial value_rejected __attribute__((loader_uninitialized)) {};
55 // expected-error@-1 {{variable with 'loader_uninitialized' attribute cannot have an initializer}}
57 struct nontrivial
59 nontrivial() {}
62 nontrivial needs_trivial_ctor __attribute__((loader_uninitialized));
63 // expected-error@-1 {{variable with 'loader_uninitialized' attribute must have a trivial default constructor}}
65 struct Incomplete;
66 Incomplete incomplete __attribute__((loader_uninitialized));
67 // expected-error@-1 {{variable has incomplete type 'Incomplete'}}
68 // expected-note@-3 {{forward declaration of 'Incomplete'}}
70 struct Incomplete s_incomplete __attribute__((loader_uninitialized));
71 // expected-error@-1 {{variable has incomplete type 'struct Incomplete'}}
72 // expected-note@-7 {{forward declaration of 'Incomplete'}}