diff options
author | Andrew Cagney <ac131313@redhat.com> | 2002-03-26 15:36:37 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@gcc.gnu.org> | 2002-03-26 15:36:37 +0000 |
commit | 173028e5ab8009adf8df8c023ed7a9d71328fe3d (patch) | |
tree | 94846cf8b81e58eaebeff467b95dc20837930bef /gcc/testsuite/gcc.dg/Wswitch-enum.c | |
parent | e14365a7382302adc4144d493bbbb28275e467fc (diff) | |
download | gcc-173028e5ab8009adf8df8c023ed7a9d71328fe3d.zip gcc-173028e5ab8009adf8df8c023ed7a9d71328fe3d.tar.gz gcc-173028e5ab8009adf8df8c023ed7a9d71328fe3d.tar.bz2 |
Add -Wswitch-enum. Document.
Fix PR c/5044.
From-SVN: r51386
Diffstat (limited to 'gcc/testsuite/gcc.dg/Wswitch-enum.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/Wswitch-enum.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/Wswitch-enum.c b/gcc/testsuite/gcc.dg/Wswitch-enum.c new file mode 100644 index 0000000..00e4b55 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wswitch-enum.c @@ -0,0 +1,63 @@ +/* PR c/5044 */ +/* { dg-do compile } */ +/* { dg-options "-Wswitch-enum" } */ + +enum e { e1, e2 }; + +int +foo (int i, int j, enum e ei, enum e ej, enum e ek, enum e el, + enum e em, enum e en, enum e eo, enum e ep) +{ + switch (i) + { + case 1: return 1; + case 2: return 2; + } + switch (j) + { + case 3: return 4; + case 4: return 3; + default: break; + } + switch (ei) + { /* { dg-warning "enumeration value `e1' not handled in switch" "enum e1" } */ + } /* { dg-warning "enumeration value `e2' not handled in switch" "enum e2" { target *-*-* } 23 } */ + switch (ej) + { /* { dg-warning "enumeration value `e1' not handled in switch" "enum e1" { target *-*-* } 28 } */ + default: break; + } /* { dg-warning "enumeration value `e2' not handled in switch" "enum e2" } */ + switch (ek) + { + case e1: return 1; + } /* { dg-warning "enumeration value `e2' not handled in switch" "enum e2" } */ + switch (el) + { + case e1: return 1; + default: break; + } /* { dg-warning "enumeration value `e2' not handled in switch" "enum e2" } */ + switch (em) + { + case e1: return 1; + case e2: return 2; + } + switch (en) + { + case e1: return 1; + case e2: return 2; + default: break; + } + switch (eo) + { + case e1: return 1; + case e2: return 2; + case 3: return 3; + } /* { dg-warning "case value `3' not in enumerated type `e'" "excess 3" } */ + switch (ep) + { + case e1: return 1; + case e2: return 2; + case 3: return 3; + default: break; + } /* { dg-warning "case value `3' not in enumerated type `e'" "excess 3" } */ + return 0; +} |