]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: move unsafe operation out of EvalConst
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Thu, 13 Apr 2023 02:31:41 +0000 (09:31 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Fri, 14 Apr 2023 17:57:49 +0000 (17:57 +0000)
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 <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/compile/internal/typecheck/const.go
src/cmd/compile/internal/typecheck/typecheck.go

index 060053bc8d45f2f9ad91f8bd9640221e3e335d67..11386f6f9a594e21214e3c8965466bcde0454d1d 100644 (file)
@@ -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
index e160265d494db2b82f403eb85d60c54116454305..51de4700a1cff091e12e2e10a4de1e078ce568c5 100644 (file)
@@ -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)