blob: 86d5dba77a39e0ec067dfbdb3ff1473f042a9c85 (
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
48
49
50
51
52
53
54
55
56
57
|
// { dg-do compile }
// { dg-options "-std=c++2b" }
int qux ();
constexpr int
foo (int x)
{
switch (x)
{
static const int v = 6;
case 12:
return v;
}
return 0;
}
constexpr int
bar (int x)
{
switch (x)
{
thread_local const int v = 7;
case 12:
return 7;
}
return 0;
}
constexpr int
baz (int x)
{
switch (x)
{
static int v = 6; // { dg-message "int v' is not const" }
case 12:
return v; // { dg-error "the value of 'v' is not usable in a constant expression" }
}
return 0;
}
constexpr int
corge (int x)
{
switch (x)
{
thread_local int v = 6; // { dg-message "int v' is not const" }
case 12:
return v; // { dg-error "the value of 'v' is not usable in a constant expression" }
}
return 0;
}
constexpr int a = foo (12);
constexpr int b = bar (12);
constexpr int c = baz (12);
constexpr int d = corge (12);
|