ok |= ctxStmt
n.Left = typecheck(n.Left, ctxType)
checkwidth(n.Left.Type)
- if n.Left.Type != nil && n.Left.Type.NotInHeap() && n.Left.Name.Param.Pragma&NotInHeap == 0 {
+ if n.Left.Type != nil && n.Left.Type.NotInHeap() && !n.Left.Name.Param.Alias && n.Left.Name.Param.Pragma&NotInHeap == 0 {
// The type contains go:notinheap types, so it
// must be marked as such (alternatively, we
// could silently propagate go:notinheap).
//go:notinheap
type t4 rune
+// Type aliases inherit the go:notinheap-ness of the type they alias.
+type nihAlias = nih
+
+type embedAlias1 struct { // ERROR "must be go:notinheap"
+ x nihAlias
+}
+type embedAlias2 [1]nihAlias // ERROR "must be go:notinheap"
+
var sink interface{}
func i() {
// Heap allocation is not okay.
var y *nih
+var y2 *struct{ x nih }
+var y3 *[1]nih
var z []nih
var w []nih
var n int
func g() {
- y = new(nih) // ERROR "heap allocation disallowed"
- z = make([]nih, 1) // ERROR "heap allocation disallowed"
- z = append(z, x) // ERROR "heap allocation disallowed"
+ y = new(nih) // ERROR "heap allocation disallowed"
+ y2 = new(struct{ x nih }) // ERROR "heap allocation disallowed"
+ y3 = new([1]nih) // ERROR "heap allocation disallowed"
+ z = make([]nih, 1) // ERROR "heap allocation disallowed"
+ z = append(z, x) // ERROR "heap allocation disallowed"
// Test for special case of OMAKESLICECOPY
x := make([]nih, n) // ERROR "heap allocation disallowed"
copy(x, z)