blob: b01f728291d25414dfdf68dd86104d29ac15ce68 (
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
|
// P2242R3
// { dg-do compile }
// { dg-options "-std=c++2b" }
constexpr int
foo ()
{
lab:
return 1;
}
constexpr int
bar (int x)
{
if (x)
goto lab; // { dg-error "'goto' is not a constant expression" }
return 1;
lab:
return 0;
}
constexpr int
baz (int x)
{
if (!x)
return 1;
static int a; // { dg-error "control passes through definition of 'a' with static storage duration" }
return ++a;
}
constexpr int
qux (int x)
{
if (!x)
return 1;
thread_local int a; // { dg-error "control passes through definition of 'a' with thread storage duration" }
return ++a;
}
struct S { S (); ~S (); int s; }; // { dg-message "'S::S\\\(\\\)' declared here" }
constexpr int
corge (int x)
{
if (!x)
return 1;
S s; // { dg-error "call to non-'constexpr' function 'S::S\\\(\\\)'" }
return 0;
}
constexpr int a = bar (1); // { dg-message "in 'constexpr' expansion of" }
constexpr int b = baz (1); // { dg-message "in 'constexpr' expansion of" }
constexpr int c = qux (1); // { dg-message "in 'constexpr' expansion of" }
constexpr int d = corge (1); // { dg-message "in 'constexpr' expansion of" }
|