From: Keith Randall Date: Mon, 19 Dec 2016 17:15:04 +0000 (-0800) Subject: cmd/compile: test for correct zeroing X-Git-Tag: go1.8rc1~86 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8d2169104467a14dea5705beb8ea351c68c5595d;p=gostls13.git cmd/compile: test for correct zeroing Make sure we generate the right code for zeroing a structure. Check in after Matthew's CL (34564). Update #18370 Change-Id: I987087f979d99227a880b34c44d9d4de6c25ba0c Reviewed-on: https://go-review.googlesource.com/34565 Reviewed-by: Matthew Dempsky Reviewed-by: Brad Fitzpatrick Run-TryBot: Keith Randall --- diff --git a/src/cmd/compile/internal/gc/asm_test.go b/src/cmd/compile/internal/gc/asm_test.go index 2e5d7e7488..945b74ca8c 100644 --- a/src/cmd/compile/internal/gc/asm_test.go +++ b/src/cmd/compile/internal/gc/asm_test.go @@ -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