aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/typecheck/stmt.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-06-22 18:15:21 -0700
committerMatthew Dempsky <mdempsky@google.com>2021-06-23 04:03:47 +0000
commit493e177639140d83807ae72b6ea840ce025416ce (patch)
tree50302ed0097659d80ba20e5d068ec01175c81fa4 /src/cmd/compile/internal/typecheck/stmt.go
parentc4e0c652fbf3b17cc89f72c6569fe255fe5e1047 (diff)
downloadgo-493e177639140d83807ae72b6ea840ce025416ce.tar.gz
go-493e177639140d83807ae72b6ea840ce025416ce.zip
[dev.typeparams] cmd/compile: allow typecheck of OCHECKNIL
This CL makes OCHECKNIL typecheckable. Simplifies IR construction code slightly, and gives one convenient place to check for misuse. Change-Id: I280b8e47eddcac12947a41d6f911b25bc12a66bf Reviewed-on: https://go-review.googlesource.com/c/go/+/330194 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/stmt.go')
-rw-r--r--src/cmd/compile/internal/typecheck/stmt.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/typecheck/stmt.go b/src/cmd/compile/internal/typecheck/stmt.go
index 922a01bfbe..cd00f1b3d1 100644
--- a/src/cmd/compile/internal/typecheck/stmt.go
+++ b/src/cmd/compile/internal/typecheck/stmt.go
@@ -237,6 +237,15 @@ func plural(n int) string {
return "s"
}
+// tcCheckNil typechecks an OCHECKNIL node.
+func tcCheckNil(n *ir.UnaryExpr) ir.Node {
+ n.X = Expr(n.X)
+ if !n.X.Type().IsPtrShaped() {
+ base.FatalfAt(n.Pos(), "%L is not pointer shaped", n.X)
+ }
+ return n
+}
+
// tcFor typechecks an OFOR node.
func tcFor(n *ir.ForStmt) ir.Node {
Stmts(n.Init())