aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/consteval-prop9.C
blob: 9c4a23389ce8ec8d141309824e873eed2514850a (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
// P2564R3
// { dg-do compile { target c++20 } }

consteval int
zero (int)
{
  return 0;
}

constexpr int
f1 (auto i)
{
  return zero (i);
}

constexpr int
f2 (auto i)
{
  return f1 (i);
}

constexpr int
f3 (auto i)
{
  return f2 (i);
}

constexpr int
f4 (auto i)
{
  return f3 (i);
}

constexpr int
f5 (auto i)
{
  return f4 (i);
}

constexpr int
f6 (auto)
{
  // This call is a constant expression, so don't promote f6.
  return f5 (42);
}

constexpr int
f7 (auto)
{
  // This call is a constant expression, so don't promote f7.
  return zero (42);
}

auto p1 = &f5<int>; // { dg-error "taking address" }
static auto p2 = &f4<int>; // { dg-error "taking address" }
auto p3 = &f6<int>;
static auto p4 = &f6<int>;
auto p5 = &f7<int>;
static auto p6 = &f7<int>;

void
g ()
{
  static auto q1 = &f4<int>; // { dg-error "taking address" }
  static auto q2 = &f6<int>;
  static auto q3 = &f7<int>;
}