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