forked from golang/go
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release-branch.go1.17] cmd/compile: only update source type when pro…
…cessing struct/array This is backport of CL 3651594, with the test from CL 360057. CL 360057 fixed missing update source type in storeArgOrLoad. However, we should only update the type when processing struct/array. If we update the type right before calling storeArgOrLoad, we may generate a value with invalid type, e.g, OpStructSelect with non-struct type. Fixes golang#49392 Change-Id: Ib7e10f72f818880f550aae5c9f653db463ce29b0 Reviewed-on: https://go-review.googlesource.com/c/go/+/361594 Trust: Cuong Manh Le <[email protected]> Run-TryBot: Cuong Manh Le <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: David Chase <[email protected]> Reviewed-on: https://go-review.googlesource.com/c/go/+/361596 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Keith Randall <[email protected]>
- Loading branch information
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// compile -l | ||
|
||
// Copyright 2021 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package p | ||
|
||
func f() int { | ||
var a, b struct { | ||
s struct { | ||
s struct { | ||
byte | ||
float32 | ||
} | ||
} | ||
} | ||
_ = a | ||
|
||
return func() int { | ||
return func() int { | ||
a = struct { | ||
s struct { | ||
s struct { | ||
byte | ||
float32 | ||
} | ||
} | ||
}{b.s} | ||
return 0 | ||
}() | ||
}() | ||
} | ||
|
||
func g() int { | ||
var a, b struct { | ||
s [1][1]struct { | ||
byte | ||
float32 | ||
} | ||
} | ||
_ = a | ||
|
||
return func() int { | ||
return func() int { | ||
a = struct { | ||
s [1][1]struct { | ||
byte | ||
float32 | ||
} | ||
}{b.s} | ||
return 0 | ||
}() | ||
}() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// compile | ||
|
||
// Copyright 2021 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package p | ||
|
||
func f(i int) { | ||
var s1 struct { | ||
s struct{ s struct{ i int } } | ||
} | ||
var s2, s3 struct { | ||
a struct{ i int } | ||
b int | ||
} | ||
func() { | ||
i = 1 + 2*i + s3.a.i + func() int { | ||
s2.a, s2.b = s3.a, s3.b | ||
return 0 | ||
}() + func(*int) int { | ||
return s1.s.s.i | ||
}(new(int)) | ||
}() | ||
} |