From fedfecef5e3e78daf0d970d8edb4ab33a167535c Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Tue, 3 Jun 2014 17:35:34 +0000 Subject: re PR c/60439 (No warning for case overflow in switch statement.) PR c/60439 * doc/invoke.texi: Document -Wswitch-bool. * function.c (stack_protect_epilogue): Cast controlling expression of the switch to int. * gengtype.c (walk_type): Generate switch expression with its controlling expression cast to int. c/ * c-parser.c (c_parser_switch_statement): Pass explicit_cast_p to c_start_case. * c-tree.h (c_start_case): Update. * c-typeck.c (c_start_case): Add new boolean parameter. Warn if switch condition has boolean value. cp/ * semantics.c (finish_switch_cond): Warn if switch condition has boolean value. c-family/ * c.opt (Wswitch-bool): New option. testsuite/ * c-c++-common/pr60439.c: New test. * g++.dg/eh/scope1.C (f4): Add dg-warning. From-SVN: r211194 --- gcc/function.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/function.c') diff --git a/gcc/function.c b/gcc/function.c index ec2ea26..922f567 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -4649,7 +4649,7 @@ stack_protect_epilogue (void) /* Allow the target to compare Y with X without leaking either into a register. */ - switch (HAVE_stack_protect_test != 0) + switch ((int) (HAVE_stack_protect_test != 0)) { case 1: tmp = gen_stack_protect_test (x, y, label); -- cgit v1.1