comparison gcc/testsuite/g++.dg/cpp1y/constexpr-86767.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 // PR c++/86767
2 // { dg-do compile { target c++14 } }
3
4 constexpr int
5 fn0 () noexcept
6 {
7 int r = 0;
8 for (int i = 0; i < 10; ++i)
9 {
10 continue;
11 r++;
12 for (int j = 0; j < 10; ++j )
13 {
14 }
15 }
16 return r;
17 }
18 static_assert (fn0 () == 0, "");
19
20 constexpr int
21 fn1 () noexcept
22 {
23 int r = 0;
24 for (int i = 0; i < 10; ++i)
25 for (int j = 0; j < 10; ++j)
26 {
27 continue;
28 r++;
29 }
30 return r;
31 }
32 static_assert (fn1 () == 0, "");
33
34 constexpr int
35 fn2 () noexcept
36 {
37 int r = 0;
38 for (int i = 0; i < 10; ++i)
39 {
40 continue;
41 r++;
42 }
43 return r;
44 }
45 static_assert (fn2 () == 0, "");
46
47 constexpr int
48 fn3 () noexcept
49 {
50 int r = 0;
51 for (int i = 0; i < 10; ++i)
52 {
53 continue;
54 r++;
55 while (1)
56 {
57 }
58 }
59 return r;
60 }
61 static_assert (fn3 () == 0, "");
62
63 constexpr int
64 fn4 () noexcept
65 {
66 for (int i = 0; i < 10; ++i)
67 {
68 switch (i)
69 {
70 case 5:
71 return i;
72 default:
73 continue;
74 }
75 while (1)
76 {
77 }
78 }
79 return 0;
80 }
81 static_assert (fn4 () == 5, "");
82
83 constexpr int
84 fn5 () noexcept
85 {
86 for (int i = 0; i < 10; ++i)
87 {
88 switch (i)
89 {
90 case 0:
91 case 1:
92 case 2:
93 case 3:
94 case 4:
95 continue;
96 default:
97 return i;
98 }
99 while (1)
100 {
101 }
102 }
103 return 0;
104 }
105 static_assert (fn5 () == 5, "");
106
107 constexpr int
108 fn6 () noexcept
109 {
110 int r = 0;
111 for (int i = 0; i < 10; ++i)
112 {
113 continue;
114 for (int j = 0; j < 10; ++j )
115 r++;
116 }
117 return r;
118 }
119 static_assert (fn6 () == 0, "");