]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: test for correct zeroing
authorKeith Randall <khr@golang.org>
Mon, 19 Dec 2016 17:15:04 +0000 (09:15 -0800)
committerKeith Randall <khr@golang.org>
Mon, 19 Dec 2016 17:36:35 +0000 (17:36 +0000)
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 <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>

src/cmd/compile/internal/gc/asm_test.go

index 2e5d7e748822dc31b7d099aeb9ccc0a56de301a1..945b74ca8c5509a516bf20aeece036fc6d2fc962 100644 (file)
@@ -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