From: Ian Lance Taylor Date: Sat, 19 Feb 2011 04:36:33 +0000 (+0000) Subject: Don't crash on out of range switch value. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d128a6bbe4b50d1c2d035d4cf59b9ab38f398159;p=gcc.git Don't crash on out of range switch value. From-SVN: r170305 --- diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc index bb5a6a09d0b..99ed6653914 100644 --- a/gcc/go/gofrontend/statements.cc +++ b/gcc/go/gofrontend/statements.cc @@ -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);