From: Cuong Manh Le Date: Thu, 13 Apr 2023 02:31:41 +0000 (+0700) Subject: cmd/compile: move unsafe operation out of EvalConst X-Git-Tag: go1.21rc1~896 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=47e2d7495fabaae8cfe2e1a0f0ff1e38f6e7b851;p=gostls13.git cmd/compile: move unsafe operation out of EvalConst So future CLs can get rid of EvalConst entirely. Change-Id: Ic8e147fd76e53c002a6ceda2fb3be979459bf865 Reviewed-on: https://go-review.googlesource.com/c/go/+/484315 Reviewed-by: Keith Randall Reviewed-by: Matthew Dempsky Run-TryBot: Cuong Manh Le Reviewed-by: Keith Randall TryBot-Result: Gopher Robot --- diff --git a/src/cmd/compile/internal/typecheck/const.go b/src/cmd/compile/internal/typecheck/const.go index 060053bc8d..11386f6f9a 100644 --- a/src/cmd/compile/internal/typecheck/const.go +++ b/src/cmd/compile/internal/typecheck/const.go @@ -496,10 +496,6 @@ func EvalConst(n ir.Node) ir.Node { } } - case ir.OALIGNOF, ir.OOFFSETOF, ir.OSIZEOF: - n := n.(*ir.UnaryExpr) - return OrigInt(n, evalunsafe(n)) - case ir.OREAL: n := n.(*ir.UnaryExpr) nl := n.X diff --git a/src/cmd/compile/internal/typecheck/typecheck.go b/src/cmd/compile/internal/typecheck/typecheck.go index e160265d49..51de4700a1 100644 --- a/src/cmd/compile/internal/typecheck/typecheck.go +++ b/src/cmd/compile/internal/typecheck/typecheck.go @@ -608,7 +608,7 @@ func typecheck1(n ir.Node, top int) ir.Node { case ir.OALIGNOF, ir.OOFFSETOF, ir.OSIZEOF: n := n.(*ir.UnaryExpr) n.SetType(types.Types[types.TUINTPTR]) - return n + return OrigInt(n, evalunsafe(n)) case ir.OCAP, ir.OLEN: n := n.(*ir.UnaryExpr)