comparison gcc/testsuite/c-c++-common/pr66322.c @ 16:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
comparison
equal deleted inserted replaced
15:561a7518be6b 16:04ced10e8804
1 /* PR c/66322 */
2 /* { dg-do compile } */
3
4 #ifndef __cplusplus
5 # define bool _Bool
6 # define true 1
7 # define false 0
8 #endif
9
10 void
11 nowarn (bool b)
12 {
13 switch (b)
14 ;
15
16 switch (b)
17 {
18 case true:
19 case false:
20 break;
21 }
22
23 switch (b)
24 {
25 case true:
26 break;
27 }
28
29 switch (b)
30 {
31 case true:
32 default:
33 break;
34 }
35
36 switch (b)
37 {
38 case false:
39 break;
40 }
41
42 switch (b)
43 {
44 case false:
45 default:
46 break;
47 }
48
49 switch (b)
50 {
51 default:
52 break;
53 }
54
55 switch (b)
56 {
57 case false ... true:
58 break;
59 }
60
61 switch (b)
62 {
63 case 1:
64 switch (b)
65 {
66 case true:
67 default:
68 break;
69 }
70 default:
71 break;
72 }
73 }
74
75 void
76 warn (bool b)
77 {
78 switch (b) /* { dg-warning "switch condition has" } */
79 {
80 case true:
81 case false:
82 default:
83 break;
84 }
85
86 switch (b) /* { dg-warning "switch condition has" } */
87 {
88 case false ... true:
89 default:
90 break;
91 }
92 }
93
94 void
95 warn2 (int n)
96 {
97 switch (n == 2) /* { dg-warning "switch condition has" } */
98 {
99 case 0 ... 2: /* { dg-warning "upper value" "" { target c++ } } */
100 default:
101 break;
102 }
103
104 switch (n == 2) /* { dg-warning "switch condition has" } */
105 {
106 case 1 ... 10: /* { dg-warning "upper value" "" { target c++ } } */
107 default:
108 break;
109 }
110
111 switch (n == 2) /* { dg-warning "switch condition has" } */
112 {
113 case 2: /* { dg-warning "case label" "" { target c++ } } */
114 break;
115 }
116
117 switch (n == 2) /* { dg-warning "switch condition has" } */
118 {
119 case 0:
120 case 1:
121 case -1: /* { dg-warning "case label" "" { target c++ } } */
122 break;
123 }
124
125 switch (n == 2) /* { dg-warning "switch condition has" } */
126 {
127 case -1 ... 1: /* { dg-warning "lower value" "" { target c++ } } */
128 break;
129 }
130
131 switch (n == 2) /* { dg-warning "switch condition has" } */
132 {
133 case -1 ... 0: /* { dg-warning "lower value" "" { target c++ } } */
134 default:
135 break;
136 }
137
138 switch (n == 2) /* { dg-warning "switch condition has" } */
139 {
140 case -10 ... -1: /* { dg-warning "case label" "" { target c++ } } */
141 default:
142 break;
143 }
144 }