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 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}} 10 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}} 14 15 int noargs __attribute__((loader_uninitialized(0))); 16 // expected-error@-1 {{'loader_uninitialized' attribute takes no arguments}} 17 18 int init_rejected __attribute__((loader_uninitialized)) = 42; 19 // expected-error@-1 {{variable with 'loader_uninitialized' attribute cannot have an initializer}} 20 21 void func() __attribute__((loader_uninitialized)) 22 // expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}} 23 { 24 int local __attribute__((loader_uninitialized)); 25 // expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}} 26 27 static int sl __attribute__((loader_uninitialized)); 28 } 29 30 struct s { 31 __attribute__((loader_uninitialized)) int field; 32 // expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}} 33 34 static __attribute__((loader_uninitialized)) int sfield; 35 36 } __attribute__((loader_uninitialized)); 37 // expected-warning@-1 {{'loader_uninitialized' attribute only applies to global variables}} 38 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}} 43 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}} 50 51 struct trivial {}; 52 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}} 56 57 struct nontrivial 58 { 59 nontrivial() {} 60 }; 61 62 nontrivial needs_trivial_ctor __attribute__((loader_uninitialized)); 63 // expected-error@-1 {{variable with 'loader_uninitialized' attribute must have a trivial default constructor}} 64 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'}} 69 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'}} 73