Commit 2c11164d authored by Russ Cox's avatar Russ Cox

cmd/compile: fix value range check for complex constants

Fixes #11590.

Change-Id: I4144107334604a2cc98c7984df3b5d4cde3d30af
Reviewed-on: https://go-review.googlesource.com/16920Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 292ad592
......@@ -259,7 +259,6 @@ func convlit1(np **Node, t *Type, explicit bool) {
n.SetVal(toint(n.Val()))
fallthrough
// flowthrough
case CTINT:
overflow(n.Val(), t)
}
......@@ -272,7 +271,6 @@ func convlit1(np **Node, t *Type, explicit bool) {
n.SetVal(toflt(n.Val()))
fallthrough
// flowthrough
case CTFLT:
n.SetVal(Val{truncfltlit(n.Val().U.(*Mpflt), t)})
}
......@@ -283,6 +281,7 @@ func convlit1(np **Node, t *Type, explicit bool) {
case CTFLT, CTINT, CTRUNE:
n.SetVal(tocplx(n.Val()))
fallthrough
case CTCPLX:
overflow(n.Val(), t)
......
// errorcheck
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package p
var _ = int8(4) * 300 // ERROR "constant overflows int8"
var _ = complex64(1) * 1e200 // ERROR "constant overflows complex64"
var _ = complex128(1) * 1e500 // ERROR "constant overflows complex128"
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