Debian Codegraph @

gcc/testsuite/g++.dg/gomp/sharing-1.C

raw
1 /* { dg-do compile } */
2 /* { dg-require-effective-target tls } */
3
4 int thrglobalvar;
5 #pragma omp threadprivate (thrglobalvar)
6 int globalvar;
7 const struct S
8 {
9 int x;
10 } constvar = { 8 };
11 struct T
12 {
13 static T t;
14 int i;
15 };
16 T T::t = { 6 };
17 /* const qualified type, but mutable member -> not predetermined. */
18 const struct U
19 {
20 int x;
21 mutable int y;
22 } constmutvar = { 6, 4 };
23
24 int
25 foo (int x)
26 {
27 return x;
28 }
29
30 int
31 bar (int *x)
32 {
33 return *x;
34 }
35
36 int
37 baz (U u)
38 {
39 return u.x;
40 }
41
42 int
43 main (void)
44 {
45 static int thrlocvar;
46 #pragma omp threadprivate (thrlocvar)
47 static int locvar;
48 static int *p;
49 int i, j, s, l;
50
51 p = new int;
52 *p = 7;
53 s = 6;
54 l = 0;
55 #pragma omp parallel for /* { dg-message "note: enclosing 'parallel'" } */ \
56 default (none) private (p) shared (s)
57 for (i = 0; i < 64; i++)
58 {
59 int k = foo (0); /* Predetermined - private (automatic var declared */
60 k++; /* in scope of construct). */
61 thrglobalvar++; /* Predetermined - threadprivate. */
62 thrlocvar++; /* Predetermined - threadprivate. */
63 foo (i); /* Predetermined - private (omp for loop variable). */
64 foo (constvar.x); /* { dg-error "not specified in" } */
65 foo (T::t.i); /* Predetermined - shared (static data member). */
66 foo (*p); /* *p predetermined - shared (heap allocated */
67 (*p)++; /* storage). */
68 bar (p); /* Explicitly determined - private. */
69 foo (s); /* Explicitly determined - shared. */
70 globalvar++; /* { dg-error "not specified in" } */
71 locvar++; /* { dg-error "not specified in" } */
72 l++; /* { dg-error "not specified in" } */
73 for (j = 0; j < 2; j++); /* { dg-error "not specified in" } */
74 baz (constmutvar);/* { dg-error "not specified in" } */
75 }
76 return 0;
77 }