1 // RUN: %clang_cc1 -fsyntax-only -verify %s 2 // RUN: %clang_cc1 -fsyntax-only -DSYSTEM -verify %s 3 4 #if defined(SYSTEM) 5 #5 "init-priority-attr.cpp" 3 // system header 6 #endif 7 8 class Two { 9 private: 10 int i, j, k; 11 public: 12 static int count; 13 Two( int ii, int jj ) { i = ii; j = jj; k = count++; }; 14 Two( void ) { i = 0; j = 0; k = count++; }; 15 int eye( void ) { return i; }; 16 int jay( void ) { return j; }; 17 int kay( void ) { return k; }; 18 }; 19 20 extern Two foo; 21 extern Two goo; 22 extern Two coo[]; 23 extern Two koo[]; 24 25 Two foo __attribute__((init_priority(101))) ( 5, 6 ); 26 27 Two goo __attribute__((init_priority(2,3))) ( 5, 6 ); // expected-error {{'init_priority' attribute takes one argument}} 28 29 Two coo[2] __attribute__((init_priority(100))); 30 #if !defined(SYSTEM) 31 // expected-error@-2 {{'init_priority' attribute requires integer constant between 101 and 65535 inclusive}} 32 #endif 33 34 Two boo[2] __attribute__((init_priority(65536))); 35 #if !defined(SYSTEM) 36 // expected-error@-2 {{'init_priority' attribute requires integer constant between 101 and 65535 inclusive}} 37 #endif 38 39 Two koo[4] __attribute__((init_priority(1.13))); // expected-error {{'init_priority' attribute requires an integer constant}} 40 41 Two func() __attribute__((init_priority(1001))); // expected-error {{'init_priority' attribute only applies to variables}} 42 43 int i __attribute__((init_priority(1001))); // expected-error {{can only use 'init_priority' attribute on file-scope definitions of objects of class type}} 44 45 int main() { 46 Two foo __attribute__((init_priority(1001))); // expected-error {{can only use 'init_priority' attribute on file-scope definitions of objects of class type}} 47 } 48