summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tls/pic-1.c
blob: 9108b58aa5034e487ed90e46fae26e70a4c598fe (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* { dg-do compile } */
/* { dg-require-effective-target fpic } */
/* { dg-options "-O2 -fpic -ftls-model=global-dynamic" } */
/* { dg-require-effective-target tls } */

extern __thread long e1;
extern __thread int e2;
static __thread long s1;
static __thread int s2;

long *ae1 (void)
{
  return &e1;
}

int *ae2 (void)
{
  return &e2;
}

long *as1 (void)
{
  return &s1;
}

int *as2 (void)
{
  return &s2;
}

long ge1 (void)
{
  return e1;
}

int ge2 (void)
{
  return e2;
}

long gs1 (void)
{
  return s1;
}

int gs2 (void)
{
  return s2;
}

long ge3 (void)
{
  return e1 + e2;
}

long gs3 (void)
{
  return s1 + s2;
}

long ge4 (void)
{
  if (0)
    return e1;
  return e2;
}

long gs4 (void)
{
  if (0)
    return s1;
  return s2;
}