Handle peeling for alignment with masking
[official-gcc.git] / gcc / testsuite / gcc.dg / pragma-diag-3.c
blobb6ee60f16770924a1e882f10b0c9376ff040c568
1 /* { dg-do compile } */
2 /* { dg-options "-Wswitch-enum -Wsign-compare -fstrict-overflow -Wstrict-overflow -Werror -Wno-error=switch-enum" } */
3 /* PR c/66098 - #pragma diagnostic 'ignored' not fully undone by pop for strict-overflow
4 PR c/66711 - GCC does not correctly restore diagnostic state after pragma GCC diagnostic pop with -Werror
5 */
6 /* { dg-message "warnings being treated as errors" "" {target "*-*-*"} 0 } */
8 void testing2() {
9 #pragma GCC diagnostic push
10 #pragma GCC diagnostic ignored "-Wstrict-overflow"
11 int j = 4;
12 j + 4 < j;
13 #pragma GCC diagnostic pop
16 void testing3() {
17 int k = 4;
18 k + 4 < k; /* { dg-error "overflow" "" { xfail *-*-* } } */
21 int bar()
23 unsigned x = 0;
24 int y = 1;
26 /* generates an error - ok */
27 x += x < y ? 1 : 0; /* { dg-error "comparison" } */
29 #pragma GCC diagnostic push
30 #pragma GCC diagnostic ignored "-Wsign-compare"
31 /* generates no diagnostic - ok */
32 x += x < y ? 1 : 0;
33 #pragma GCC diagnostic pop
35 x += x < y ? 1 : 0; /* { dg-error "comparison" } */
37 return x;
40 enum EE { ONE, TWO };
42 int f (enum EE e)
44 int r = 0;
46 #pragma GCC diagnostic push
47 #pragma GCC diagnostic ignored "-Wswitch-enum"
49 switch (e)
51 case ONE:
52 r = 1;
53 break;
55 #pragma GCC diagnostic pop
57 switch (e) /* { dg-warning "switch" } */
59 case ONE:
60 r = 1;
61 break;
63 return r;