| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-require-effective-target tls } */ |
| 3 |
|
| 4 |
#include <stdlib.h> |
| 5 |
|
| 6 |
int thrglobalvar; |
| 7 |
#pragma omp threadprivate (thrglobalvar) |
| 8 |
int globalvar; |
| 9 |
const int constvar = 8; |
| 10 |
|
| 11 |
int |
| 12 |
foo (int x) |
| 13 |
{ |
| 14 |
return x; |
| 15 |
} |
| 16 |
|
| 17 |
int |
| 18 |
bar (int *x) |
| 19 |
{ |
| 20 |
return *x; |
| 21 |
} |
| 22 |
|
| 23 |
int |
| 24 |
main (void) |
| 25 |
{ |
| 26 |
static int thrlocvar; |
| 27 |
#pragma omp threadprivate (thrlocvar) |
| 28 |
static int locvar; |
| 29 |
static int *p; |
| 30 |
int i, j, s, l; |
| 31 |
|
| 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-message "note: enclosing 'parallel'" } */ \ |
| 39 |
default (none) private (p) shared (s) |
| 40 |
for (i = 0; i < 64; i++) |
| 41 |
{ |
| 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); /* { dg-error "not specified in" } */ |
| 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" } */ |
| 56 |
} |
| 57 |
return 0; |
| 58 |
} |