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]

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



On Dec 14, 2004, at 1:02 PM, Mark Mitchell wrote:


Andrew Pinski wrote:
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.

The concept is OK, but this comment:


+ /* Check to see if the HIGH_BOUND overlaps. The low end of that
+ range is bigger than the low end of the current range, so we
+ are only interested if the current range is a real range, and
+ not an ordinary case label. */


which makes sense, does not seem to be implemented. You're checking high_bound for non-NULL, not whether or not the current case is really a range.

And this is what I applied (though it took me about 8 months to finish up).


I bootstrapped and tested it on powerpc-darwin with no regressions.

Thanks,
Andrew Pinski

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.

Testsuite/ChangeLog:
	* gcc.dg/switch-warn-3.c: New test.


Attachment: fixPR18715.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]