gcc/testsuite/gcc.dg/Wenum-conversion.c
raw| 1 | /* { dg-do compile } */ |
| 2 | /* { dg-options "-Wenum-conversion" } */ |
| 3 | |
| 4 | enum X { x1, x2 }; |
| 5 | enum Y { y1, y2 }; |
| 6 | |
| 7 | enum X obj = y1; /* { dg-warning "implicit conversion from .enum Y. to .enum X." } */ |
| 8 | enum Y obj2 = y1; |
| 9 | |
| 10 | enum X obj3; |
| 11 | void foo() |
| 12 | { |
| 13 | obj3 = y2; /* { dg-warning "implicit conversion from .enum Y. to .enum X." } */ |
| 14 | } |
| 15 | |
| 16 | void bar(enum X); |
| 17 | void f(void) |
| 18 | { |
| 19 | bar (y1); /* { dg-warning "implicit conversion from .enum Y. to .enum X." } */ |
| 20 | } |