[PATCH] Fix PR C/18715, warning about enum not handled with ...

Andrew Pinski pinskia@physics.uc.edu
Tue Dec 14 14:33:00 GMT 2004


The problem here is that we don't find the node in splay tree if it was 
not
an exact match for the lower bound.  We need to look to see if there is 
a
predecessor or a successor so that the enum value fits in the value of 
the
CASE statement.  This patch implements that, copying from 
c_add_case_label.
This should not have a slow down if you don't use ranges in switches
and implements all enums.

OK? Bootstrapped and tested on powerpc-darwin with no regression.

Thanks,
Andrew Pinski

Testcase:
/* { dg-options "" } */
enum a { a0, a1, a2, a3 };

int error(enum a aa)
{
   switch ( aa ) /* { dg-bogus "" } */
   {
   case a0 ... a3:
     return 1;
   }
   return 0;
}

ChangeLog:

	* c-common.c (c_do_switch_warnings): Look for a node where the enum's
	value is inbetween the range if we did not find an exact match.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: temp.diff.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20041214/b77d4858/attachment.txt>


More information about the Gcc-patches mailing list