aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc.dg/torture/tls/thr-init-2.m
blob: b637e2544e683cd049a427431b87be40420f6274 (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
// { dg-do run }
// { dg-require-effective-target tls }
/* { dg-skip-if "PR44140" { *-*-* } { "-flto" "-fwhopr" } { "" } } */

extern void _exit(int);

__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 ) 
    _exit (-(__LINE__)) ;

  a = fa(glb);
  if ( a != 6 ) 
    _exit (-(__LINE__)) ;

  a = fb(a);  
  if ( a != 10 || glb != 10 ) 
    _exit (-(__LINE__)) ;
  
  return 0;
}