Don't crash on out of range switch value.
authorIan Lance Taylor <ian@gcc.gnu.org>
Sat, 19 Feb 2011 04:36:33 +0000 (04:36 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Sat, 19 Feb 2011 04:36:33 +0000 (04:36 +0000)
From-SVN: r170305

gcc/go/gofrontend/statements.cc

index bb5a6a09d0b571cc48040d11b032435e69100a69..99ed6653914efd39b5d07bf9226929c3768fd67a 100644 (file)
@@ -3212,7 +3212,12 @@ Case_clauses::Case_clause::get_constant_tree(Translate_context* context,
          mpz_t ival;
          mpz_init(ival);
          if (!(*p)->integer_constant_value(true, ival, &itype))
-           gcc_unreachable();
+           {
+             // Something went wrong.  This can happen with a
+             // negative constant and an unsigned switch value.
+             gcc_assert(saw_errors());
+             continue;
+           }
          gcc_assert(itype != NULL);
          tree type_tree = itype->get_tree(context->gogo());
          tree val = Expression::integer_constant_tree(ival, type_tree);