summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp1z/constexpr-if29.C
blob: a40912a6fa5594d0fd0f70f939da75076a176393 (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
// PR c++/85827
// { dg-do compile { target c++17 } }
// { dg-options "-Wunused-variable -Wunused-parameter" }

template <int N> int f()
{
    constexpr bool _1 = N == 1;
    constexpr bool _2 = N == 2;
    constexpr bool _3 = N == 3;
    
    if constexpr (_1) {
        return 5;
    } else if constexpr (_2) {
        return 1;
    } else if constexpr (_3) {
        return 7;
    }
}

int a() {
    return f<1>();
}
int b() {
    return f<2>();
}
int c() {
    return f<3>();
}