mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: never report "truncated to real" for toint calls
Whoever called toint() is expecting the {Mpint, Mpflt, Mpcplx} arg to
be converted to an integer expression, so it never makes sense to
report an error as "constant X truncated to real".
Fixes #11580
Change-Id: Iadcb105f0802358a7f77188c2b1e63fe80c5580c
Reviewed-on: https://go-review.googlesource.com/34638
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
8b11e0b42d
commit
871300308a
2 changed files with 3 additions and 5 deletions
|
|
@ -458,12 +458,10 @@ func toint(v Val) Val {
|
|||
|
||||
case *Mpcplx:
|
||||
i := new(Mpint)
|
||||
if i.SetFloat(&u.Real) < 0 {
|
||||
if i.SetFloat(&u.Real) < 0 || u.Imag.CmpFloat64(0) != 0 {
|
||||
yyerror("constant %v%vi truncated to integer", fconv(&u.Real, FmtSharp), fconv(&u.Imag, FmtSharp|FmtSign))
|
||||
}
|
||||
if u.Imag.CmpFloat64(0) != 0 {
|
||||
yyerror("constant %v%vi truncated to real", fconv(&u.Real, FmtSharp), fconv(&u.Imag, FmtSharp|FmtSign))
|
||||
}
|
||||
|
||||
v.U = i
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue