1/* { dg-do compile } */ 2/* { dg-require-effective-target tls_native } */ 3 4int thrglobalvar; 5#pragma omp threadprivate (thrglobalvar) 6int globalvar; 7const struct S 8{ 9 int x; 10} constvar = { 8 }; 11struct T 12{ 13 static T t; 14 int i; 15}; 16T T::t = { 6 }; 17/* const qualified type, but mutable member -> not predetermined. */ 18const struct U 19{ 20 int x; 21 mutable int y; 22} constmutvar = { 6, 4 }; 23 24int 25foo (int x) 26{ 27 return x; 28} 29 30int 31bar (int *x) 32{ 33 return *x; 34} 35 36int 37baz (U u) 38{ 39 return u.x; 40} 41 42int 43main (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-error "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); /* Predetermined - shared (const qualified type). */ 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} 78