PR other/25028
[official-gcc.git] / gcc / testsuite / gcc.dg / tls / opt-6.c
blob8a01c019c10b99cc4e9080ea268ff8fa7d59b94e
1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
3 /* { dg-require-effective-target tls } */
5 extern void abort (void);
6 extern void exit (int);
8 struct A
10 char a;
11 int b;
12 long long c;
14 extern __thread struct A a1, a2, a3, a4;
15 extern struct A *f1a (void);
16 extern struct A *f2a (void);
17 extern struct A *f3a (void);
18 extern struct A *f4a (void);
19 extern struct A *f5a (void);
20 extern struct A *f6a (void);
21 extern struct A *f7a (void);
22 extern struct A *f8a (void);
23 extern struct A *f9a (void);
24 extern struct A *f10a (void);
25 extern int f1b (void);
26 extern int f2b (void);
27 extern int f3b (void);
28 extern int f4b (void);
29 extern int f5b (void);
30 extern int f6b (void);
31 extern int f7b (void);
32 extern int f8b (void);
33 extern int f9b (void);
34 extern int f10b (void);
35 extern void check1 (void);
36 extern void check2 (void);
37 __thread int dummy = 12;
38 __thread struct A local = { 1, 2, 3 };
40 int
41 main (void)
43 struct A *p;
45 if (local.a != 1 || local.b != 2 || local.c != 3)
46 abort ();
47 if (a1.a != 4 || a1.b != 5 || a1.c != 6)
48 abort ();
49 if (a2.a != 22 || a2.b != 23 || a2.c != 24)
50 abort ();
51 if (a3.a != 10 || a3.b != 11 || a3.c != 12)
52 abort ();
53 if (a4.a != 25 || a4.b != 26 || a4.c != 27)
54 abort ();
55 check1 ();
56 check2 ();
57 if (f1a () != &a1 || f2a () != &a2 || f3a () != &a3 || f4a () != &a4)
58 abort ();
59 p = f5a (); if (p->a != 16 || p->b != 16 + 1 || p->c != 16 + 2)
60 abort ();
61 p = f6a (); if (p->a != 19 || p->b != 19 + 1 || p->c != 19 + 2)
62 abort ();
63 if (f7a () != &a2 || f8a () != &a4)
64 abort ();
65 p = f9a (); if (p->a != 28 || p->b != 28 + 1 || p->c != 28 + 2)
66 abort ();
67 p = f10a (); if (p->a != 31 || p->b != 31 + 1 || p->c != 31 + 2)
68 abort ();
70 exit (0);