Commit f4274e64 authored by Matthew Dempsky's avatar Matthew Dempsky Committed by Dmitri Shuralyov
Browse files

[release-branch.go1.14] cmd/compile: fix constant conversion involving complex types

In CL 187657, I refactored constant conversion logic without realizing
that conversions between int/float and complex types are allowed for
constants (assuming the constant values are representable by the
destination type), but are never allowed for non-constant expressions.

This CL expands convertop to take an extra srcConstant parameter to
indicate whether the source expression is a constant; and if so, to
allow any numeric-to-numeric conversion. (Conversions of values that
cannot be represented in the destination type are rejected by
evconst.)

Fixes #38123.
For #38117.

Change-Id: Id7077d749a14c8fd910be38da170fa5254819f2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/226197


Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
(cherry picked from commit 34314280)
Reviewed-on: https://go-review.googlesource.com/c/go/+/232719


Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent b7eca1cf
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment