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