2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.dg / tls / opt-4.c
blob3a95688963b20723b8210154e12dbf6d3a37a4eb
1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
4 struct A
6 int a1;
7 int a2;
8 };
10 extern __thread const unsigned char *tcc1, **tcc2;
12 extern inline const unsigned char ** __attribute__ ((const))
13 foo (void)
15 const unsigned char **a = &tcc1;
16 if (*a == 0)
17 *a = *tcc2 + 128;
18 return a;
21 extern inline int
22 bar (const struct A *x)
24 int a;
26 if (x->a2 & 8)
27 return 0;
28 a = x->a1;
29 return a > 0 && ((*foo ())[a] & 64);
32 int
33 baz (const struct A *x, char *y)
35 const struct A *a;
37 for (a = x; !!a->a1; a++)
38 if (! (x->a2 & 8))
39 if (bar (a))
41 *y++ = a->a1;
42 if (x->a1)
43 *y++ = ':';
44 *y = '\0';
46 return 0;
49 /* Verify tcc1 and tcc2 variables show up only in the TLS access sequences. */
50 /* { dg-final { scan-assembler "tcc1@" { target i?86-*-* x86_64-*-* } } } */
51 /* { dg-final { scan-assembler "tcc2@" { target i?86-*-* x86_64-*-* } } } */
52 /* { dg-final { scan-assembler-not "tcc1\[^@\]" { target i?86-*-* x86_64-*-* } } } */
53 /* { dg-final { scan-assembler-not "tcc2\[^@\]" { target i?86-*-* x86_64-*-* } } } */