2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.dg / special / initp1.C
blobadde34fefa64453a7561421599bedaa57ceb5970
1 /* This doesn't work on solaris2 for reasons described in PR 6482.  */
2 /* { dg-do run { xfail *-*-solaris2* } } */
3 #include <stdlib.h>
5 class Two {
6 private:
7     int i, j, k;
8 public:
9     static int count;
10     Two( int ii, int jj ) { i = ii; j = jj; k = count++; };
11     Two( void )           { i =  0; j =  0; k = count++; };
12     int eye( void ) { return i; };
13     int jay( void ) { return j; };
14     int kay( void ) { return k; };
17 extern Two foo;
18 extern Two goo;
19 extern Two coo[];
20 extern Two koo[];
22 Two foo __attribute__((init_priority(1005))) ( 5, 6 );
24 Two goo __attribute__((init_priority(1007))) = Two( 7, 8 );
26 Two doo[ 3 ];
28 Two hoo[ 3 ] = {
29     Two( 11, 12 ),
30     Two( 13, 14 ),
31     Two( 15, 16 )
34 Two coo[ 3 ] __attribute__((init_priority(1000)));
36 Two koo[ 3 ] __attribute__((init_priority(1000))) = {
37     Two( 21, 22 ),
38     Two( 23, 24 ),
39     Two( 25, 26 )
42 Two xoo[ 3 ] __attribute__((init_priority(1100)));
44 Two zoo[ 3 ] __attribute__((init_priority(1100))) = {
45     Two( 31, 32 ),
46     Two( 33, 34 ),
47     Two( 35, 36 )
50 int Two::count;
52 long x = 0;
54 #define X( n ) \
55   do { if ( x & (1L << (n)) ) return 1; else x |= (1L << (n)); } while (0)
57 int main()
60     X( coo[0].kay() );
61     X( coo[1].kay() );
62     X( coo[2].kay() );
63     X( koo[0].kay() );
64     X( koo[1].kay() );
65     X( koo[2].kay() );
66     if ( 0x3f != x ) abort ();
68     X( foo.kay() );
69     if ( 0x7f != x ) abort ();
71     X( goo.kay() );
72     if ( 0xff != x ) abort ();
74     X( xoo[0].kay() );
75     X( xoo[1].kay() );
76     X( xoo[2].kay() );
77     X( zoo[0].kay() );
78     X( zoo[1].kay() );
79     X( zoo[2].kay() );
80     if ( 0x3fff != x ) abort ();
82     X( doo[0].kay() );
83     X( doo[1].kay() );
84     X( doo[2].kay() );
85     X( hoo[0].kay() );
86     X( hoo[1].kay() );
87     X( hoo[2].kay() );
88     if ( 0xfffff != x ) abort ();
90     exit (0);