This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.

Attachment: temp.diff.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]