[dev.ssa] cmd/compile/internal/ssa: implement OCFUNC

Change-Id: Ieb9cddf8876bf8cd5ee1705d9210d22c3959e8cc
Reviewed-on: https://go-review.googlesource.com/14329
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Todd Neal <todd@tneal.org>
diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go
index 386420f..4fe8ba8 100644
--- a/src/cmd/compile/internal/gc/ssa.go
+++ b/src/cmd/compile/internal/gc/ssa.go
@@ -1203,6 +1203,9 @@
 
 	s.stmtList(n.Ninit)
 	switch n.Op {
+	case OCFUNC:
+		aux := &ssa.ExternSymbol{n.Type, n.Left.Sym}
+		return s.entryNewValue1A(ssa.OpAddr, n.Type, aux, s.sb)
 	case ONAME:
 		if n.Class == PFUNC {
 			// "value" of a function is the address of the function's closure
@@ -1296,16 +1299,17 @@
 	case OCONVNOP:
 		to := n.Type
 		from := n.Left.Type
-		if to.Etype == TFUNC {
-			s.Unimplementedf("CONVNOP closure")
-			return nil
-		}
 
 		// Assume everything will work out, so set up our return value.
 		// Anything interesting that happens from here is a fatal.
 		x := s.expr(n.Left)
 		v := s.newValue1(ssa.OpCopy, to, x) // ensure that v has the right type
 
+		// CONVNOP closure
+		if to.Etype == TFUNC && from.IsPtr() {
+			return v
+		}
+
 		// named <--> unnamed type or typed <--> untyped const
 		if from.Etype == to.Etype {
 			return v