Merge from mainline
[official-gcc.git] / gcc / testsuite / gcc.dg / gomp / sharing-1.c
blob90d389b7292592fcb53f02997f5d8d07dde48d39
1 /* { dg-do compile } */
2 /* { dg-require-effective-target tls } */
4 #include <stdlib.h>
6 int thrglobalvar;
7 #pragma omp threadprivate (thrglobalvar)
8 int globalvar;
9 const int constvar = 8;
11 int
12 foo (int x)
14 return x;
17 int
18 bar (int *x)
20 return *x;
23 int
24 main (void)
26 static int thrlocvar;
27 #pragma omp threadprivate (thrlocvar)
28 static int locvar;
29 static int *p;
30 int i, j, s, l;
32 p = malloc (sizeof (int));
33 if (p == NULL)
34 return 0;
35 *p = 7;
36 s = 6;
37 l = 0;
38 #pragma omp parallel for /* { dg-error "enclosing parallel" } */ \
39 default (none) private (p) shared (s)
40 for (i = 0; i < 64; i++)
42 int k = foo (0); /* Predetermined - private (automatic var declared */
43 k++; /* in scope of construct). */
44 thrglobalvar++; /* Predetermined - threadprivate. */
45 thrlocvar++; /* Predetermined - threadprivate. */
46 foo (i); /* Predetermined - private (omp for loop variable). */
47 foo (constvar); /* Predetermined - shared (const qualified type). */
48 foo (*p); /* *p predetermined - shared (heap allocated */
49 (*p)++; /* storage). */
50 bar (p); /* Explicitly determined - private. */
51 foo (s); /* Explicitly determined - shared. */
52 globalvar++; /* { dg-error "not specified in" } */
53 locvar++; /* { dg-error "not specified in" } */
54 l++; /* { dg-error "not specified in" } */
55 for (j = 0; j < 2; j++); /* { dg-error "not specified in" } */
57 return 0;