mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-01-28 09:54:23 +08:00
re PR c/4475 (-Wswitch option not functional)
* gcc.dg/Wswitch.c: New test. PR gcc/4475. PR gcc/3780. From-SVN: r49462
This commit is contained in:
parent
02ae22b851
commit
ffe80457ad
@ -1,3 +1,8 @@
|
||||
2002-02-03 Andrew Cagney <ac131313@redhat.com>
|
||||
|
||||
* gcc.dg/Wswitch.c: New test.
|
||||
PR gcc/4475. PR gcc/3780.
|
||||
|
||||
2002-02-03 Toon Moene <toon@moene.indiv.nluug.nl>
|
||||
|
||||
* g77.f-torture/execute/5122.f: New test for regressions
|
||||
|
63
gcc/testsuite/gcc.dg/Wswitch.c
Normal file
63
gcc/testsuite/gcc.dg/Wswitch.c
Normal file
@ -0,0 +1,63 @@
|
||||
/* PR gcc/4475, PR gcc/3780 */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-Wswitch" } */
|
||||
|
||||
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: return 7;
|
||||
}
|
||||
switch (ei)
|
||||
{ /* { dg-warning "enumeration value `e1' not handled in switch" "enum e1" { target *-*-* } 24 } */
|
||||
} /* { dg-warning "enumeration value `e2' not handled in switch" "enum e2" } */
|
||||
switch (ej)
|
||||
{
|
||||
default: break;
|
||||
}
|
||||
switch (ek)
|
||||
{
|
||||
case e1: return 1;
|
||||
} /* { dg-warning "enumeration value `e2' not handled in switch" "enum e1" } */
|
||||
switch (el)
|
||||
{
|
||||
case e1: return 1;
|
||||
default: break;
|
||||
}
|
||||
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;
|
||||
} /* Since there is a default, no warning about ``case 3'' } */
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user