1 // RUN: %clang_cc1 %s -verify -fsyntax-only
2 
3 int good __attribute__((loader_uninitialized));
4 static int local_ok __attribute__((loader_uninitialized));
5 int hidden_ok __attribute__((visibility("hidden"))) __attribute__((loader_uninitialized));
6 
7 const int still_cant_be_const __attribute__((loader_uninitialized));
8 // expected-error@-1 {{default initialization of an object of const type}}
9 extern int external_rejected __attribute__((loader_uninitialized));
10 // expected-error@-1 {{variable 'external_rejected' cannot be declared both 'extern' and with the 'loader_uninitialized' attribute}}
11 
12 int noargs __attribute__((loader_uninitialized(0)));
13 // expected-error@-1 {{'loader_uninitialized' attribute takes no arguments}}
14 
15 int init_rejected __attribute__((loader_uninitialized)) = 42;
16 // expected-error@-1 {{variable with 'loader_uninitialized' attribute cannot have an initializer}}
17 
func()18 void func() __attribute__((loader_uninitialized))
19 // expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}}
20 {
21   int local __attribute__((loader_uninitialized));
22   // expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}}
23 
24   static int sl __attribute__((loader_uninitialized));
25 }
26 
27 struct s {
28   __attribute__((loader_uninitialized)) int field;
29   // expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}}
30 
31   static __attribute__((loader_uninitialized)) int sfield;
32 
33 } __attribute__((loader_uninitialized));
34 // expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}}
35 
36 int redef_attr_first __attribute__((loader_uninitialized));
37 int redef_attr_first;
38 // expected-error@-1 {{redefinition of 'redef_attr_first'}}
39 // expected-note@-3 {{previous definition is here}}
40 
41 int redef_attr_second;
42 int redef_attr_second __attribute__((loader_uninitialized));
43 // expected-warning@-1 {{attribute declaration must precede definition}}
44 // expected-note@-3 {{previous definition is here}}
45 // expected-error@-3 {{redefinition of 'redef_attr_second'}}
46 // expected-note@-5 {{previous definition is here}}
47 
48 struct trivial {};
49 
50 trivial default_ok __attribute__((loader_uninitialized));
51 trivial value_rejected  __attribute__((loader_uninitialized)) {};
52 // expected-error@-1 {{variable with 'loader_uninitialized' attribute cannot have an initializer}}
53 
54 struct nontrivial
55 {
nontrivialnontrivial56   nontrivial() {}
57 };
58 
59 nontrivial needs_trivial_ctor __attribute__((loader_uninitialized));
60 // expected-error@-1 {{variable with 'loader_uninitialized' attribute must have a trivial default constructor}}
61