From c58e8676dd02e78d29512ff0f0b024ce91c62883 Mon Sep 17 00:00:00 2001 From: Volker Reichelt Date: Wed, 16 Aug 2006 20:50:18 +0000 Subject: [PATCH] re PR c/27489 (ICE on broken switch condition) PR c/27489 * c-typeck.c (c_start_case): Handle invalid orig_type correctly. Clean up. From-SVN: r116188 --- gcc/ChangeLog | 6 ++++++ gcc/c-typeck.c | 17 ++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 16644ae78df..aa17eb1d404 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2006-08-16 Volker Reichelt + + PR c/27489 + * c-typeck.c (c_start_case): Handle invalid orig_type correctly. + Clean up. + 2006-08-16 Mike Stump * doc/invoke.texi (-Wno-deprecated-declarations): Fixup use of pxref. diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 0a5aae5eb37..2fbd89f5c2d 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -7064,25 +7064,25 @@ struct c_switch *c_switch_stack; tree c_start_case (tree exp) { - enum tree_code code; - tree type, orig_type = error_mark_node; + tree orig_type = error_mark_node; struct c_switch *cs; if (exp != error_mark_node) { - code = TREE_CODE (TREE_TYPE (exp)); orig_type = TREE_TYPE (exp); - if (!INTEGRAL_TYPE_P (orig_type) - && code != ERROR_MARK) + if (!INTEGRAL_TYPE_P (orig_type)) { - error ("switch quantity not an integer"); + if (orig_type != error_mark_node) + { + error ("switch quantity not an integer"); + orig_type = error_mark_node; + } exp = integer_zero_node; - orig_type = error_mark_node; } else { - type = TYPE_MAIN_VARIANT (TREE_TYPE (exp)); + tree type = TYPE_MAIN_VARIANT (orig_type); if (!in_system_header && (type == long_integer_type_node @@ -7091,7 +7091,6 @@ c_start_case (tree exp) "converted to % in ISO C"); exp = default_conversion (exp); - type = TREE_TYPE (exp); } }