aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/typecheck/typecheck.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-06-14 12:26:41 -0700
committerMatthew Dempsky <mdempsky@google.com>2021-06-14 13:24:47 -0700
commitea438bda85ed473ecee215b098eba1f19113bc24 (patch)
tree78ea8b11917bcdf1e7c78c09c0395c684d55c054 /src/cmd/compile/internal/typecheck/typecheck.go
parent8eeaf961c50973b0aa2065d2c31dfa5d9949bf93 (diff)
parentfdab5be159c508c4c1cf5be84119fd2b38403cdf (diff)
downloadgo-ea438bda85ed473ecee215b098eba1f19113bc24.tar.gz
go-ea438bda85ed473ecee215b098eba1f19113bc24.zip
[dev.typeparams] all: merge master (fdab5be) into dev.typeparams
Two non-conflict changes included because they're needed for all.bash: 1. Bump internal/goversion.Version to 18. This will happen eventually anyway (dev.typeparams will not be merged back to Go 1.17), and is needed for cmd/api to allow new API additions. 2. Add fixedbugs/issue46725.go (new test added on master) to the list of known failures for -G=3. This test exercises a bug that was fixed in typecheck, but -G=3 mode has duplicated that code and will need to be fixed as well. That's outside of the scope of a merge. Conflicts: - src/runtime/traceback.go Nearby lines were removed on both master and dev.typeparams. Merge List: + 2021-06-14 fdab5be159 doc/go1.17: further revise OpenBSD release notes + 2021-06-14 326ea438bb cmd/compile: rewrite a, b = f() to use temporaries when type not identical + 2021-06-14 3249b645c9 cmd/compile: factor out rewrite multi-valued f() + 2021-06-13 14305bf0b9 misc/cgo: generate Windows import libraries for clang + 2021-06-13 24cff0f044 cmd/go, misc/cgo: skip test if no .edata + 2021-06-13 67b1b6a2e3 cmd/compile: allow ir.OSLICE2ARRPTR in mayCall + 2021-06-12 1ed0d129e9 runtime: testprogcgo: don't call exported Go functions directly from Go + 2021-06-12 9d46ee5ac4 reflect: handle stack-to-register translation in callMethod + 2021-06-11 e552a6d312 cmd/go: remove hint when no module is suggested + 2021-06-11 16b5d766d8 syscall: do not load native libraries on non-native powershell on arm + 2021-06-11 77aa209b38 runtime: loop on EINTR in macOS sigNoteSleep + 2021-06-11 e2dc6dd5c9 doc/go1.17: clean up formatting of gofmt section + 2021-06-11 2f1128461d cmd/go: match Windows paths in TestScript/mod_invalid_version + 2021-06-11 2721da2608 doc/go1.17: fix formatting near httptest + 2021-06-10 770f1de8c5 net/http: remove test-only private key from production binaries + 2021-06-10 8d11b1d117 cmd/go: report the imports of CompiledGoFiles in ImportMap + 2021-06-10 dc00dc6c6b crypto/tls: let HTTP/1.1 clients connect to servers with NextProtos "h2" + 2021-06-09 27f83723e9 api: promote next to go1.17 + 2021-06-09 182157c81a doc/go1.17: remove lingering TODO + 2021-06-09 a5bc060b42 doc/go1.17: document strconv changes for Go 1.17 + 2021-06-09 1402b27d46 strconv: document parsing of leading +/- + 2021-06-09 df35ade067 doc/go1.17: document //go:build lines + 2021-06-09 e4e7807d24 net/http: add AllowQuerySemicolons + 2021-06-09 ec3026d032 doc/go1.17: remove TODO for ports section + 2021-06-09 e6dda19888 net/url: reject query values with semicolons + 2021-06-09 139e935d3c math/big: comment division + 2021-06-09 aa5540cd82 cmd/compile: make map.zero symbol content-addressable + 2021-06-09 07ca28d529 cmd/link: fix bug in -strictdups checking of BSS symbols + 2021-06-08 bcecae2af6 doc/go1.17: mention new possibility of type conversion panicking + 2021-06-08 63dcab2e91 doc/go1.17: mention new vet checks sigchanyzer and stdmethods. + 2021-06-08 6551763a60 doc/go1.17: mention block profile bias fix + 2021-06-08 cb80937bf6 Revert "doc/go1.17: mention block profile bias fix" + 2021-06-08 d3e3d03666 net: reject leading zeros in IP address parsers + 2021-06-08 da4a640141 doc/go1.17: revise OpenBSD release notes + 2021-06-08 689f4c7415 doc/go1.17: mention block profile bias fix + 2021-06-08 9afe071c60 doc/go1.17: remove TODO for Tools section + 2021-06-08 f753d7223e doc/go1.17: resolve TODO for cmd/cover + 2021-06-08 9498b0155d cmd/go: in Go 1.17+ modules, add indirect go.mod dependencies separately from direct ones + 2021-06-08 949f00cebe doc/go1.17: add release notes for crypto packages + 2021-06-08 0fb3e2c184 doc/go1.17: add a release note for the '-compat' flag to 'go mod tidy' + 2021-06-08 2169deb352 cmd/compile: use t.AllMethods when sorting typesByString + 2021-06-08 c20bcb6488 runtime: remove out-of-date comments about frame skipping + 2021-06-07 39c39ae52f doc: document Go 1.17 language changes + 2021-06-07 dc8b558951 cmd/dist: pass -Wno-lto-type-mismatch in swig_callback_lto + 2021-06-07 909dd5e010 strconv: ParseFloat: always return ErrSyntax for bad syntax Change-Id: Iffdf379d0275bbd12d50149ce38634773ced481d
Diffstat (limited to 'src/cmd/compile/internal/typecheck/typecheck.go')
-rw-r--r--src/cmd/compile/internal/typecheck/typecheck.go41
1 files changed, 29 insertions, 12 deletions
diff --git a/src/cmd/compile/internal/typecheck/typecheck.go b/src/cmd/compile/internal/typecheck/typecheck.go
index a6b21f948a..8454b8d5b3 100644
--- a/src/cmd/compile/internal/typecheck/typecheck.go
+++ b/src/cmd/compile/internal/typecheck/typecheck.go
@@ -941,16 +941,18 @@ func typecheckargs(n ir.InitNode) {
return
}
- // Rewrite f(g()) into t1, t2, ... = g(); f(t1, t2, ...).
-
// Save n as n.Orig for fmt.go.
if ir.Orig(n) == n {
n.(ir.OrigNode).SetOrig(ir.SepCopy(n))
}
- as := ir.NewAssignListStmt(base.Pos, ir.OAS2, nil, nil)
- as.Rhs.Append(list...)
+ // Rewrite f(g()) into t1, t2, ... = g(); f(t1, t2, ...).
+ rewriteMultiValueCall(n, list[0])
+}
+// rewriteMultiValueCall rewrites multi-valued f() to use temporaries,
+// so the backend wouldn't need to worry about tuple-valued expressions.
+func rewriteMultiValueCall(n ir.InitNode, call ir.Node) {
// If we're outside of function context, then this call will
// be executed during the generated init function. However,
// init.go hasn't yet created it. Instead, associate the
@@ -960,25 +962,40 @@ func typecheckargs(n ir.InitNode) {
if static {
ir.CurFunc = InitTodoFunc
}
- list = nil
- for _, f := range t.FieldSlice() {
- t := Temp(f.Type)
- as.PtrInit().Append(ir.NewDecl(base.Pos, ir.ODCL, t))
- as.Lhs.Append(t)
- list = append(list, t)
+
+ as := ir.NewAssignListStmt(base.Pos, ir.OAS2, nil, []ir.Node{call})
+ results := call.Type().FieldSlice()
+ list := make([]ir.Node, len(results))
+ for i, result := range results {
+ tmp := Temp(result.Type)
+ as.PtrInit().Append(ir.NewDecl(base.Pos, ir.ODCL, tmp))
+ as.Lhs.Append(tmp)
+ list[i] = tmp
}
if static {
ir.CurFunc = nil
}
+ n.PtrInit().Append(Stmt(as))
+
switch n := n.(type) {
+ default:
+ base.Fatalf("rewriteMultiValueCall %+v", n.Op())
case *ir.CallExpr:
n.Args = list
case *ir.ReturnStmt:
n.Results = list
+ case *ir.AssignListStmt:
+ if n.Op() != ir.OAS2FUNC {
+ base.Fatalf("rewriteMultiValueCall: invalid op %v", n.Op())
+ }
+ as.SetOp(ir.OAS2FUNC)
+ n.SetOp(ir.OAS2)
+ n.Rhs = make([]ir.Node, len(list))
+ for i, tmp := range list {
+ n.Rhs[i] = AssignConv(tmp, n.Lhs[i].Type(), "assignment")
+ }
}
-
- n.PtrInit().Append(Stmt(as))
}
func checksliceindex(l ir.Node, r ir.Node, tp *types.Type) bool {