Skip to content

Commit

Permalink
compiler: Report errors after evaluating invalid constant.
Browse files Browse the repository at this point in the history
The fix for golang/go#11541 made the assertion that getting an invalid
Numeric_constant after evaluating an invalid constant must result in
an error in a binary expression.  However, a Numeric_constant can be
invalid if it is unset, which occurs when either operand cannot be
converted to the right type.  These errors are issued after the
Numeric_constant is lowered.

Fixes golang/go#12615.

Change-Id: I54e41d748a325004fde59f9e4e02d9c40f8f6576
Reviewed-on: https://go-review.googlesource.com/14646
Reviewed-by: Ian Lance Taylor <iant@golang.org>
  • Loading branch information
Chris Manghane authored and ianlancetaylor committed Oct 20, 2015
1 parent 302d8ab commit 11e249a
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions go/expressions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4909,14 +4909,7 @@ Binary_expression::do_lower(Gogo* gogo, Named_object*,
Numeric_constant nc;
if (!Binary_expression::eval_constant(op, &left_nc, &right_nc,
location, &nc))
{
if (nc.is_invalid())
{
go_assert(saw_errors());
return Expression::make_error(location);
}
return this;
}
return nc.expression(location);
}
}
Expand Down

0 comments on commit 11e249a

Please sign in to comment.