diff options
author | Keith Randall <khr@golang.org> | 2020-08-17 21:59:07 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2020-08-18 05:23:42 +0000 |
commit | a745171e6b30394b661a040d04e8807b4bd0c7da (patch) | |
tree | 4d37fa49eb61bb831928a1fbd4d6955ccffed2e8 /src/cmd/compile/internal/types/type_test.go | |
parent | 613388315e29d4e906805e602602500ca1e7e334 (diff) | |
download | go-a745171e6b30394b661a040d04e8807b4bd0c7da.tar.gz go-a745171e6b30394b661a040d04e8807b4bd0c7da.zip |
cmd/compile: fix SSA type comparison
A typo in the conversion code caused comparisons of SSA types to
report CMPeq when they were not in fact equal.
Fixes #40837
Change-Id: I0627eee51d524a585908b34a4590bc533c8415fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/248781
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Diffstat (limited to 'src/cmd/compile/internal/types/type_test.go')
-rw-r--r-- | src/cmd/compile/internal/types/type_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/types/type_test.go b/src/cmd/compile/internal/types/type_test.go new file mode 100644 index 0000000000..fe3f380b21 --- /dev/null +++ b/src/cmd/compile/internal/types/type_test.go @@ -0,0 +1,28 @@ +// Copyright 2020 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 types_test + +import ( + "cmd/compile/internal/types" + "testing" +) + +func TestSSACompare(t *testing.T) { + a := []*types.Type{ + types.TypeInvalid, + types.TypeMem, + types.TypeFlags, + types.TypeVoid, + types.TypeInt128, + } + for _, x := range a { + for _, y := range a { + c := x.Compare(y) + if x == y && c != types.CMPeq || x != y && c == types.CMPeq { + t.Errorf("%s compare %s == %d\n", x.Extra, y.Extra, c) + } + } + } +} |