summaryrefslogtreecommitdiff
path: root/gcc/testsuite/obj-c++.dg/torture/tls/thr-init-2.mm
blob: 4e3f8e6e3d176857794effcef7f94227304b0e61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// { dg-do run }
// { dg-require-effective-target tls }
// { dg-add-options tls }

extern "C" {
extern void abort ();
}

__thread int glb =1 ;

static __thread int fstat = 2;

int fa(int a)
{
static __thread int as = 3;
  as += a ;
  return as;
}

int fb(int b)
{
static __thread int bs = 4;
  bs += b ;
  glb = bs;
  return bs;
}

int main (int ac, char *av[])
{
  int a = 1;
  
  a = fa(fstat);
  if ( a != 5 ) 
    abort () ;

  a = fa(glb);
  if ( a != 6 ) 
    abort () ;

  a = fb(a);  
  if ( a != 10 || glb != 10 ) 
    abort () ;
  
  return 0;
}