cmd/vet: tests for RET checking, SP checking, and leaf functions
Add tests for recently introduced asm error checks in vet. This adds tests for the new warnings about functions that don't store to their return slot before returning or that store to SP-relative addresses in or beyond the argument frame. It also adds a test for leaf function handling on arm, where the link register is not implicitly saved. LGTM=rsc R=rsc CC=adg, golang-codereviews, r https://golang.org/cl/166040044
This commit is contained in:
parent
52f3c4bf8a
commit
348181cdd4
|
@ -22,6 +22,8 @@ func argiface(x interface{}, y interface {
|
|||
func returnint() int
|
||||
func returnbyte(x int) byte
|
||||
func returnnamed(x byte) (r1 int, r2 int16, r3 string, r4 byte)
|
||||
func returnintmissing() int
|
||||
func leaf(x, y int) int
|
||||
|
||||
func noprof(x int)
|
||||
func dupok(x int)
|
||||
|
|
|
@ -27,6 +27,9 @@ TEXT ·arg1(SB),0,$0-2
|
|||
TESTQ y+1(FP), AX // ERROR "invalid TESTQ of y\+1\(FP\); uint8 is 1-byte value"
|
||||
TESTB x+1(FP), AX // ERROR "invalid offset x\+1\(FP\); expected x\+0\(FP\)"
|
||||
TESTB y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+1\(FP\)"
|
||||
MOVB 8(SP), AX // ERROR "8\(SP\) should be x\+0\(FP\)"
|
||||
MOVB 9(SP), AX // ERROR "9\(SP\) should be y\+1\(FP\)"
|
||||
MOVB 10(SP), AX // ERROR "use of 10\(SP\) points beyond argument frame"
|
||||
RET
|
||||
|
||||
TEXT ·arg2(SB),0,$0-4
|
||||
|
@ -246,3 +249,6 @@ TEXT ·returnnamed(SB),0,$0-41
|
|||
MOVB AX, r4+40(FP)
|
||||
MOVL AX, r1+8(FP) // ERROR "invalid MOVL of r1\+8\(FP\); int is 8-byte value"
|
||||
RET
|
||||
|
||||
TEXT ·returnintmissing(SB),0,$0-8
|
||||
RET // ERROR "RET without writing to 8-byte ret\+0\(FP\)"
|
||||
|
|
|
@ -26,6 +26,9 @@ TEXT ·arg1(SB),0,$0-2
|
|||
TESTQ y+1(FP), AX // ERROR "invalid TESTQ of y\+1\(FP\); uint8 is 1-byte value"
|
||||
TESTB x+1(FP), AX // ERROR "invalid offset x\+1\(FP\); expected x\+0\(FP\)"
|
||||
TESTB y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+1\(FP\)"
|
||||
MOVB 4(SP), AX // ERROR "4\(SP\) should be x\+0\(FP\)"
|
||||
MOVB 5(SP), AX // ERROR "5\(SP\) should be y\+1\(FP\)"
|
||||
MOVB 6(SP), AX // ERROR "use of 6\(SP\) points beyond argument frame"
|
||||
RET
|
||||
|
||||
TEXT ·arg2(SB),0,$0-4
|
||||
|
@ -249,3 +252,6 @@ TEXT ·returnnamed(SB),0,$0-21
|
|||
MOVB AX, r4+20(FP)
|
||||
MOVQ AX, r1+4(FP) // ERROR "invalid MOVQ of r1\+4\(FP\); int is 4-byte value"
|
||||
RET
|
||||
|
||||
TEXT ·returnintmissing(SB),0,$0-4
|
||||
RET // ERROR "RET without writing to 4-byte ret\+0\(FP\)"
|
||||
|
|
|
@ -14,6 +14,9 @@ TEXT ·arg1(SB),0,$0-2
|
|||
MOVW y+1(FP), AX // ERROR "invalid MOVW of y\+1\(FP\); uint8 is 1-byte value"
|
||||
MOVB x+1(FP), AX // ERROR "invalid offset x\+1\(FP\); expected x\+0\(FP\)"
|
||||
MOVB y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+1\(FP\)"
|
||||
MOVB 8(R13), AX // ERROR "8\(R13\) should be x\+0\(FP\)"
|
||||
MOVB 9(R13), AX // ERROR "9\(R13\) should be y\+1\(FP\)"
|
||||
MOVB 10(R13), AX // ERROR "use of 10\(R13\) points beyond argument frame"
|
||||
RET
|
||||
|
||||
TEXT ·arg2(SB),0,$0-4
|
||||
|
@ -164,3 +167,12 @@ TEXT ·returnnamed(SB),0,$0-21
|
|||
MOVB AX, r4+20(FP)
|
||||
MOVB AX, r1+4(FP) // ERROR "invalid MOVB of r1\+4\(FP\); int is 4-byte value"
|
||||
RET
|
||||
|
||||
TEXT ·returnintmissing(SB),0,$0-4
|
||||
RET // ERROR "RET without writing to 4-byte ret\+0\(FP\)"
|
||||
|
||||
TEXT ·leaf(SB),0,$-4-12
|
||||
MOVW x+0(FP), AX
|
||||
MOVW y+4(FP), AX
|
||||
MOVW AX, ret+8(FP)
|
||||
RET
|
||||
|
|
Loading…
Reference in New Issue