gotypes: fix argument size for signatures without return types (#212)

This fixes a bug in argument size calculation in the case where the function
has no return values. Previously it was padding the argument struct to max
alignment, but this only happens if there are return values following.

Updates #191
This commit is contained in:
Michael McLoughlin
2021-10-30 13:32:25 -07:00
committed by GitHub
parent e70c62b254
commit 7de02518a2
7 changed files with 61 additions and 5 deletions

View File

@@ -0,0 +1,15 @@
//go:build ignore
// +build ignore
package main
import (
. "github.com/mmcloughlin/avo/build"
)
func main() {
TEXT("Uint16", 0, "func(n uint16)")
Doc("Uint16 tests argument size without return types.")
RET()
Generate()
}

View File

@@ -0,0 +1,4 @@
// Package issue191 tests for correct argument size for a function taking a
// single uint16 argument. Prior to the fix, this test case triggered an asmdecl
// error.
package issue191

View File

@@ -0,0 +1,5 @@
// Code generated by command: go run asm.go -out issue191.s -stubs stub.go. DO NOT EDIT.
// func Uint16(n uint16)
TEXT ·Uint16(SB), $0-2
RET

View File

@@ -0,0 +1,9 @@
package issue191
import "testing"
//go:generate go run asm.go -out issue191.s -stubs stub.go
func TestUint16(t *testing.T) {
Uint16(42)
}

View File

@@ -0,0 +1,6 @@
// Code generated by command: go run asm.go -out issue191.s -stubs stub.go. DO NOT EDIT.
package issue191
// Uint16 tests argument size without return types.
func Uint16(n uint16)