| 1 |
// PR c++/108607 |
| 2 |
// { dg-do compile { target c++14 } } |
| 3 |
// { dg-options "-fopenmp" } |
| 4 |
|
| 5 |
constexpr int |
| 6 |
bar (int x) |
| 7 |
{ |
| 8 |
return x; |
| 9 |
} |
| 10 |
|
| 11 |
constexpr int |
| 12 |
foo (int x) |
| 13 |
{ |
| 14 |
#pragma omp scope // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 15 |
x = bar (x); |
| 16 |
return x; |
| 17 |
} |
| 18 |
|
| 19 |
constexpr int |
| 20 |
baz (int x) |
| 21 |
{ |
| 22 |
switch (x) |
| 23 |
{ |
| 24 |
case 42: |
| 25 |
return 0; |
| 26 |
case 2: |
| 27 |
#pragma omp scope // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 28 |
x = bar (x); |
| 29 |
return x; |
| 30 |
case 3: |
| 31 |
#pragma omp parallel // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 32 |
x = bar (x); |
| 33 |
return x; |
| 34 |
case 4: |
| 35 |
#pragma omp task // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 36 |
x = bar (x); |
| 37 |
return x; |
| 38 |
default: |
| 39 |
return -1; |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
constexpr int a = foo (1); |
| 44 |
constexpr int b = baz (42); |
| 45 |
constexpr int c = baz (2); |
| 46 |
constexpr int d = baz (3); |
| 47 |
constexpr int e = baz (4); |