OSDN Git Service

233cf20e132fd41af56a3579c87cf18a5031e601
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / obj-c++.dg / torture / tls / thr-init-2.mm
1 // { dg-do run }
2 // { dg-require-effective-target tls }
3 /* { dg-skip-if "PR44140" { *-*-* } { "-flto" "-fwhopr" } { "" } } */
4
5 extern "C" {
6 extern void abort ();
7 }
8
9 __thread int glb =1 ;
10
11 static __thread int fstat = 2;
12
13 int fa(int a)
14 {
15 static __thread int as = 3;
16   as += a ;
17   return as;
18 }
19
20 int fb(int b)
21 {
22 static __thread int bs = 4;
23   bs += b ;
24   glb = bs;
25   return bs;
26 }
27
28 int main (int ac, char *av[])
29 {
30   int a = 1;
31   
32   a = fa(fstat);
33   if ( a != 5 ) 
34     abort () ;
35
36   a = fa(glb);
37   if ( a != 6 ) 
38     abort () ;
39
40   a = fb(a);  
41   if ( a != 10 || glb != 10 ) 
42     abort () ;
43   
44   return 0;
45 }