Skip to content

Commit

Permalink
cmd/compile: test for correct zeroing
Browse files Browse the repository at this point in the history
Make sure we generate the right code for zeroing a structure.

Check in after Matthew's CL (34564).

Update golang#18370

Change-Id: I987087f979d99227a880b34c44d9d4de6c25ba0c
Reviewed-on: https://go-review.googlesource.com/34565
Reviewed-by: Matthew Dempsky <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
Run-TryBot: Keith Randall <[email protected]>
  • Loading branch information
randall77 committed Dec 19, 2016
1 parent 0919fd7 commit 8d21691
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/cmd/compile/internal/gc/asm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,19 @@ func f(b []byte, i int) uint32 {
`,
[]string{"\tMOVL\t\\(.*\\)\\(.*\\*1\\),"},
},

// Structure zeroing. See issue #18370.
{"amd64", "linux", `
type T struct {
a, b, c int
}
func f(t *T) {
*t = T{}
}
`,
[]string{"\tMOVQ\t\\$0, \\(.*\\)", "\tMOVQ\t\\$0, 8\\(.*\\)", "\tMOVQ\t\\$0, 16\\(.*\\)"},
},
// TODO: add a test for *t = T{3,4,5} when we fix that.
}

// mergeEnvLists merges the two environment lists such that
Expand Down

0 comments on commit 8d21691

Please sign in to comment.