Mercurial > hg > CbC > CbC_gcc
annotate gcc/testsuite/g++.dg/cpp1z/constexpr-if29.C @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | |
children |
rev | line source |
---|---|
145 | 1 // PR c++/85827 |
2 // { dg-do compile { target c++17 } } | |
3 // { dg-options "-Wunused-variable -Wunused-parameter" } | |
4 | |
5 template <int N> int f() | |
6 { | |
7 constexpr bool _1 = N == 1; | |
8 constexpr bool _2 = N == 2; | |
9 constexpr bool _3 = N == 3; | |
10 | |
11 if constexpr (_1) { | |
12 return 5; | |
13 } else if constexpr (_2) { | |
14 return 1; | |
15 } else if constexpr (_3) { | |
16 return 7; | |
17 } | |
18 } | |
19 | |
20 int a() { | |
21 return f<1>(); | |
22 } | |
23 int b() { | |
24 return f<2>(); | |
25 } | |
26 int c() { | |
27 return f<3>(); | |
28 } |