Skip to content

Commit cd5362c

Browse files
Chris Manghaneianlancetaylor
Chris Manghane
authored andcommitted
compiler: Don't crash on invalid arithmetic ops.
The gofrontend would crash after hitting an unreachable state while trying to determine the type of an arithmetic expression involving non-numeric values. Instead of crashing, it should fail gracefully if the relevant error is already reported. Fixes golang/go#11537. Change-Id: I84ec06bb944b8af34ec5e5864a5149c11c782919 Reviewed-on: https://go-review.googlesource.com/13793 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent d5e6af4 commit cd5362c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

go/expressions.cc

+5-1
Original file line numberDiff line numberDiff line change
@@ -15150,7 +15150,11 @@ Numeric_constant::set_type(Type* type, bool issue_error, Location loc)
1515015150
else if (type->complex_type() != NULL)
1515115151
ret = this->check_complex_type(type->complex_type(), issue_error, loc);
1515215152
else
15153-
go_unreachable();
15153+
{
15154+
ret = false;
15155+
if (issue_error)
15156+
go_assert(saw_errors());
15157+
}
1515415158
if (ret)
1515515159
this->type_ = type;
1515615160
return ret;

0 commit comments

Comments
 (0)