comparison gcc/testsuite/g++.dg/warn/pr81275-2.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 sanitizer/81875
2 // { dg-do compile }
3 // { dg-options "-Wreturn-type" }
4
5 struct C { C (); ~C (); };
6
7 int
8 f1 (int a, int b)
9 {
10 C f;
11 switch (a)
12 {
13 case 0:
14 switch (b)
15 {
16 case 13:
17 return 7;
18 case 24:
19 return 19;
20 case 25:
21 return 0;
22 }
23 break;
24 default:
25 return 0;
26 case 9:
27 return 17;
28 }
29 } // { dg-warning "control reaches end of non-void function" }
30
31 int
32 f2 (int a, int b, int c, int d)
33 {
34 C f;
35 switch (a)
36 {
37 case 0:
38 switch (b)
39 {
40 case 13:
41 while (c >= 10)
42 {
43 if (c == d)
44 break;
45 c--;
46 }
47 return 7;
48 case 29:
49 switch (d)
50 {
51 case 35:
52 break;
53 default:
54 return 9;
55 }
56 return 8;
57 case 24:
58 do
59 {
60 if (c == d)
61 break;
62 c--;
63 }
64 while (c >= 10);
65 return 19;
66 case 25:
67 for (int e = 0; e < c; ++e)
68 if (e == d)
69 break;
70 return 0;
71 }
72 break;
73 default:
74 return 0;
75 case 9:
76 return 17;
77 }
78 } // { dg-warning "control reaches end of non-void function" }
79
80 template <int N>
81 int
82 f3 (int a, int b)
83 {
84 C f;
85 switch (a)
86 {
87 case 0:
88 switch (b)
89 {
90 case 13:
91 return 7;
92 case 24:
93 return 19;
94 case 25:
95 return 0;
96 }
97 break;
98 default:
99 return 0;
100 case 9:
101 return 17;
102 }
103 } // { dg-warning "control reaches end of non-void function" }
104
105 template <int N>
106 int
107 f4 (int a, int b, int c, int d)
108 {
109 C f;
110 switch (a)
111 {
112 case 0:
113 switch (b)
114 {
115 case 13:
116 while (c >= 10)
117 {
118 if (c == d)
119 break;
120 c--;
121 }
122 return 7;
123 case 29:
124 switch (d)
125 {
126 case 35:
127 break;
128 default:
129 return 9;
130 }
131 return 8;
132 case 24:
133 do
134 {
135 if (c == d)
136 break;
137 c--;
138 }
139 while (c >= 10);
140 return 19;
141 case 25:
142 for (int e = 0; e < c; ++e)
143 if (e == d)
144 break;
145 return 0;
146 }
147 break;
148 default:
149 return 0;
150 case 9:
151 return 17;
152 }
153 } // { dg-warning "control reaches end of non-void function" }
154
155 int
156 f5 (int a, int b)
157 {
158 return f3 <0> (a, b);
159 }
160
161 int
162 f6 (int a, int b, int c, int d)
163 {
164 return f4 <2> (a, b, c, d);
165 }