blob: fc8d4b1feb556acde4fc7fd8e97e59842bd03b4a (
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
|
/* { dg-do compile } */
/* { dg-options "-Wsign-compare -Werror=sign-compare -Werror=switch-enum" } */
/* { dg-message "warnings being treated as errors" "" {target "*-*-*"} 0 } */
int bar()
{
unsigned x = 0;
int y = 1;
/* generates an error - ok */
x += x < y ? 1 : 0; /* { dg-error "comparison" } */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-compare"
/* generates no diagnostic - ok */
x += x < y ? 1 : 0;
#pragma GCC diagnostic pop
x += x < y ? 1 : 0; /* { dg-error "comparison" } */
return x;
}
enum EE { ONE, TWO };
int f (enum EE e)
{
int r = 0;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-enum"
switch (e)
{
case ONE:
r = 1;
break;
}
#pragma GCC diagnostic pop
switch (e) /* { dg-error "switch" } */
{
case ONE:
r = 1;
break;
}
return r;
}
|