From d128a6bbe4b50d1c2d035d4cf59b9ab38f398159 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Sat, 19 Feb 2011 04:36:33 +0000 Subject: [PATCH] Don't crash on out of range switch value. From-SVN: r170305 --- gcc/go/gofrontend/statements.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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); -- 2.30.2