xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/init-priority-attr.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc class Two {
4f4a2713aSLionel Sambuc private:
5f4a2713aSLionel Sambuc     int i, j, k;
6f4a2713aSLionel Sambuc public:
7f4a2713aSLionel Sambuc     static int count;
Two(int ii,int jj)8f4a2713aSLionel Sambuc     Two( int ii, int jj ) { i = ii; j = jj; k = count++; };
Two(void)9f4a2713aSLionel Sambuc     Two( void )           { i =  0; j =  0; k = count++; };
eye(void)10f4a2713aSLionel Sambuc     int eye( void ) { return i; };
jay(void)11f4a2713aSLionel Sambuc     int jay( void ) { return j; };
kay(void)12f4a2713aSLionel Sambuc     int kay( void ) { return k; };
13f4a2713aSLionel Sambuc };
14f4a2713aSLionel Sambuc 
15f4a2713aSLionel Sambuc extern Two foo;
16f4a2713aSLionel Sambuc extern Two goo;
17f4a2713aSLionel Sambuc extern Two coo[];
18f4a2713aSLionel Sambuc extern Two koo[];
19f4a2713aSLionel Sambuc 
20f4a2713aSLionel Sambuc Two foo __attribute__((init_priority(101))) ( 5, 6 );
21f4a2713aSLionel Sambuc 
22f4a2713aSLionel Sambuc Two goo __attribute__((init_priority(2,3))) ( 5, 6 ); // expected-error {{'init_priority' attribute takes one argument}}
23f4a2713aSLionel Sambuc 
24f4a2713aSLionel Sambuc Two coo[2]  __attribute__((init_priority(3)));	// expected-error {{init_priority attribute requires integer constant between 101 and 65535 inclusive}}
25f4a2713aSLionel Sambuc 
26f4a2713aSLionel Sambuc Two koo[4]  __attribute__((init_priority(1.13))); // expected-error {{'init_priority' attribute requires an integer constant}}
27f4a2713aSLionel Sambuc 
28*0a6a1f1dSLionel Sambuc Two func()  __attribute__((init_priority(1001))); // expected-error {{'init_priority' attribute only applies to variables}}
29f4a2713aSLionel Sambuc 
30f4a2713aSLionel Sambuc int i  __attribute__((init_priority(1001))); // expected-error {{can only use 'init_priority' attribute on file-scope definitions of objects of class type}}
31f4a2713aSLionel Sambuc 
main()32f4a2713aSLionel Sambuc int main() {
33f4a2713aSLionel Sambuc 	Two foo __attribute__((init_priority(1001)));	// expected-error {{can only use 'init_priority' attribute on file-scope definitions of objects of class type}}
34f4a2713aSLionel Sambuc }
35f4a2713aSLionel Sambuc 
36