aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/consteval-prop3.C
blob: f181cb32942174dd70457470d2255c38dcc6af39 (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
// P2564R3
// { dg-do compile { target c++20 } }
// Cribbed from clang's cxx2b-consteval-propagate.cpp.

consteval int id(int i) { return i; }

template <typename T>
constexpr int f(T t);

auto a1 = &f<char>;
auto b1 = &f<int>;

template <typename T>
constexpr int f(T t) {
    return id(0);
}

template <typename T>
constexpr int f2(T);

auto a2 = &f2<char>; // { dg-error "taking address" }
auto b2 = &f2<int>; // { dg-error "taking address" }

template <typename T>
constexpr int f2(T t) {
    return id(t);
}