blob: 7952d495d8bf082aa8a3a962af6eaf6d77a7bbcd (
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// P2564R3
// { dg-do compile { target c++20 } }
// Test unevaluated operands.
consteval int id (int i) { return i; }
constexpr int
f1 (auto i)
{
// Unevaluated operand -> don't promote.
auto p = sizeof (&id);
(void) p;
return i;
}
constexpr int
f2 (auto i)
{
// Unevaluated operand -> don't promote.
auto p = noexcept (id);
(void) p;
return i;
}
constexpr int
f3 (auto i)
{
// Unevaluated operand -> don't promote.
auto p = noexcept (id (i));
(void) p;
return i;
}
constexpr int
f4 (auto i)
{
// Unevaluated operand -> don't promote.
decltype(id) p;
(void) p;
return i;
}
constexpr int
f5 (auto i)
{
// Unevaluated operand -> don't promote.
__extension__ auto p = alignof (id (i));
(void) p;
return i;
}
constexpr int
f6 (auto i) requires requires { id (i); }
{
return i;
}
void
g (int non_const)
{
f1 (42);
f1 (non_const);
f2 (42);
f2 (non_const);
f3 (42);
f3 (non_const);
f4 (42);
f4 (non_const);
f5 (42);
f5 (non_const);
f6 (42);
f6 (non_const);
}
|