Commit d128a6bb by Ian Lance Taylor

Don't crash on out of range switch value.

From-SVN: r170305
parent 6f6961cf
...@@ -3212,7 +3212,12 @@ Case_clauses::Case_clause::get_constant_tree(Translate_context* context, ...@@ -3212,7 +3212,12 @@ Case_clauses::Case_clause::get_constant_tree(Translate_context* context,
mpz_t ival; mpz_t ival;
mpz_init(ival); mpz_init(ival);
if (!(*p)->integer_constant_value(true, ival, &itype)) 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); gcc_assert(itype != NULL);
tree type_tree = itype->get_tree(context->gogo()); tree type_tree = itype->get_tree(context->gogo());
tree val = Expression::integer_constant_tree(ival, type_tree); tree val = Expression::integer_constant_tree(ival, type_tree);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment