comparison gcc/testsuite/g++.dg/cpp1y/constexpr-88983.C @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 // PR c++/88983
2 // { dg-do compile { target c++14 } }
3
4 constexpr int
5 fn1 (int ay)
6 {
7 switch (ay)
8 {
9 if (1)
10 {
11 case 1:
12 return 1;
13 }
14 else
15 {
16 default:;
17 }
18 }
19
20 return 0;
21 }
22
23 constexpr int
24 fn2 (int ay)
25 {
26 switch (ay)
27 {
28 if (1)
29 {
30 case 1:
31 break;
32 }
33 else
34 {
35 default:;
36 }
37 }
38
39 return 0;
40 }
41
42 constexpr int
43 fn3 (int ay)
44 {
45 int i = 0;
46 while (i++ < 100)
47 {
48 if (i == 1)
49 return 1;
50 switch (ay)
51 {
52 if (1)
53 {
54 case 1:
55 continue;
56 }
57 else
58 {
59 default:;
60 return -1;
61 }
62 }
63 return -1;
64 }
65
66 return -1;
67 }
68
69 static_assert (fn1 (1) == 1, "");
70 static_assert (fn2 (1) == 0, "");
71 static_assert (fn3 (1) == 1, "");