Commit 0e993e39 by Ian Lance Taylor

compiler: Report errors after evaluating invalid constant.

    
    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.
    
    Reviewed-on: https://go-review.googlesource.com/14646

From-SVN: r229098
parent 28c64f64
302d8abbc499e28088d758ae8b2c024d8e50b9b3 11e249a59e8c627fe9c2938c38e39cb1efefb1fb
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -4909,14 +4909,7 @@ Binary_expression::do_lower(Gogo* gogo, Named_object*, ...@@ -4909,14 +4909,7 @@ Binary_expression::do_lower(Gogo* gogo, Named_object*,
Numeric_constant nc; Numeric_constant nc;
if (!Binary_expression::eval_constant(op, &left_nc, &right_nc, if (!Binary_expression::eval_constant(op, &left_nc, &right_nc,
location, &nc)) location, &nc))
{
if (nc.is_invalid())
{
go_assert(saw_errors());
return Expression::make_error(location);
}
return this; return this;
}
return nc.expression(location); return nc.expression(location);
} }
} }
......
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