| 1 |
// { dg-do compile { target c++11 } } |
| 2 |
|
| 3 |
constexpr int |
| 4 |
f () |
| 5 |
{ |
| 6 |
int a = 42; |
| 7 |
#pragma omp parallel for simd /* { dg-error "OpenMP directives may not appear in 'constexpr' functions" } */ |
| 8 |
for (int i=0; i < 10; i++) |
| 9 |
a += i; |
| 10 |
return a; |
| 11 |
} // { dg-error "not a return-statement" "" { target c++11_down } } |
| 12 |
|
| 13 |
constexpr int |
| 14 |
g () |
| 15 |
{ |
| 16 |
int a = 42; |
| 17 |
[[omp::sequence(omp::directive(parallel),omp::directive(for))]] /* { dg-error "OpenMP directives may not appear in 'constexpr' functions" } */ |
| 18 |
for (int i=0; i < 10; i++) |
| 19 |
a += i; |
| 20 |
return a; |
| 21 |
} // { dg-error "not a return-statement" "" { target c++11_down } } |
| 22 |
|
| 23 |
constexpr int |
| 24 |
h () |
| 25 |
{ |
| 26 |
int a = 42; |
| 27 |
#pragma omp allocate(a) align(128) /* { dg-error "OpenMP directives may not appear in 'constexpr' functions" } */ |
| 28 |
return a; |
| 29 |
} // { dg-error "not a return-statement" "" { target c++11_down } } |
| 30 |
|
| 31 |
constexpr int |
| 32 |
i () |
| 33 |
{ |
| 34 |
int a [[omp::decl(allocate, align(128))]] = 42; /* { dg-error "OpenMP directives may not appear in 'constexpr' functions" } */ |
| 35 |
return a; |
| 36 |
} // { dg-error "not a return-statement" "" { target c++11_down } } |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
int main() { |
| 41 |
static constexpr int a = f (); // { dg-error "called in a constant expression" "" { target c++11_down } } |
| 42 |
static constexpr int b = g (); // { dg-error "called in a constant expression" "" { target c++11_down } } |
| 43 |
static constexpr int c = h (); // { dg-error "called in a constant expression" "" { target c++11_down } } |
| 44 |
static constexpr int d = i (); // { dg-error "called in a constant expression" "" { target c++11_down } } |
| 45 |
} |