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