OSDN Git Service

2007-09-18 Sandra Loosemore <sandra@codesourcery.com>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / tls / opt-4.c
1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
3 /* { dg-require-effective-target tls_native } */
4
5 struct A
6 {
7   int a1;
8   int a2;
9 };
10
11 extern __thread const unsigned char *tcc1, **tcc2;
12
13 extern inline const unsigned char ** __attribute__ ((const))
14 foo (void)
15 {
16   const unsigned char **a = &tcc1;
17   if (*a == 0)
18     *a = *tcc2 + 128;
19   return a;
20 }
21
22 extern inline int
23 bar (const struct A *x)
24 {
25   int a;
26
27   if (x->a2 & 8)
28     return 0;
29   a = x->a1;
30   return a > 0 && ((*foo ())[a] & 64);
31 }
32
33 int
34 baz (const struct A *x, char *y)
35 {
36   const struct A *a;
37
38   for (a = x; !!a->a1; a++)
39     if (! (x->a2 & 8))
40       if (bar (a))
41         {
42           *y++ = a->a1;
43           if (x->a1)
44             *y++ = ':';
45           *y = '\0';
46         }
47   return 0;
48 }
49
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-*-* } } } */