Reset branch to trunk.
[official-gcc.git] / trunk / gcc / testsuite / gcc.dg / tls / opt-4.c
blob3d7953b47efdae1cea565d5aad87b0c0147f6573
1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
3 /* { dg-require-effective-target tls_native } */
5 struct A
7 int a1;
8 int a2;
9 };
11 extern __thread const unsigned char *tcc1, **tcc2;
13 extern inline const unsigned char ** __attribute__ ((const))
14 foo (void)
16 const unsigned char **a = &tcc1;
17 if (*a == 0)
18 *a = *tcc2 + 128;
19 return a;
22 extern inline int
23 bar (const struct A *x)
25 int a;
27 if (x->a2 & 8)
28 return 0;
29 a = x->a1;
30 return a > 0 && ((*foo ())[a] & 64);
33 int
34 baz (const struct A *x, char *y)
36 const struct A *a;
38 for (a = x; !!a->a1; a++)
39 if (! (x->a2 & 8))
40 if (bar (a))
42 *y++ = a->a1;
43 if (x->a1)
44 *y++ = ':';
45 *y = '\0';
47 return 0;
50 /* Verify tcc1 and tcc2 variables show up only in the TLS access sequences. */
51 /* { dg-final { scan-assembler "tcc1@" { target i?86-*-* x86_64-*-* } } } */
52 /* { dg-final { scan-assembler "tcc2@" { target i?86-*-* x86_64-*-* } } } */
53 /* { dg-final { scan-assembler-not "tcc1\[^@\]" { target i?86-*-* x86_64-*-* } } } */
54 /* { dg-final { scan-assembler-not "tcc2\[^@\]" { target i?86-*-* x86_64-*-* } } } */