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