re PR c/27489 (ICE on broken switch condition)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Wed, 16 Aug 2006 20:50:18 +0000 (20:50 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Wed, 16 Aug 2006 20:50:18 +0000 (20:50 +0000)
PR c/27489
* c-typeck.c (c_start_case): Handle invalid orig_type correctly.
Clean up.

From-SVN: r116188

gcc/ChangeLog
gcc/c-typeck.c

index 16644ae78df9094968f0c94c23814185d571524a..aa17eb1d404397b29ddaafd954cd12f549d2ea8c 100644 (file)
@@ -1,3 +1,9 @@
+2006-08-16  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c/27489
+       * c-typeck.c (c_start_case): Handle invalid orig_type correctly.
+       Clean up.
+
 2006-08-16  Mike Stump  <mrs@apple.com>
 
        * doc/invoke.texi (-Wno-deprecated-declarations): Fixup use of pxref.
index 0a5aae5eb377fba820ccc6673298ca12932e0533..2fbd89f5c2db695dc284bccaa734848bff0f5f6b 100644 (file)
@@ -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 %<int%> in ISO C");
 
          exp = default_conversion (exp);
-         type = TREE_TYPE (exp);
        }
     }