Skip to content

Commit e945a4f

Browse files
committed
compiler/testdata: add structs.HostLayout
compiler/testdata: improve tests for structs.HostLayout
1 parent 64e81b3 commit e945a4f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

compiler/testdata/errors.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package main
22

3-
import "unsafe"
3+
import (
4+
"structs"
5+
"unsafe"
6+
)
47

58
//go:wasmimport modulename empty
69
func empty()
@@ -14,14 +17,15 @@ func implementation() {
1417
type Uint uint32
1518

1619
type S struct {
20+
_ structs.HostLayout
1721
a [4]uint32
1822
b uintptr
1923
d float32
2024
e float64
2125
}
2226

2327
//go:wasmimport modulename validparam
24-
func validparam(a int32, b uint64, c float64, d unsafe.Pointer, e Uint, f uintptr, g string, h *int32, i *S, j *[8]uint8)
28+
func validparam(a int32, b uint64, c float64, d unsafe.Pointer, e Uint, f uintptr, g string, h *int32, i *S, j *struct{}, k *[8]uint8)
2529

2630
// ERROR: //go:wasmimport modulename invalidparam: unsupported parameter type [4]uint32
2731
// ERROR: //go:wasmimport modulename invalidparam: unsupported parameter type []byte
@@ -35,6 +39,12 @@ func validparam(a int32, b uint64, c float64, d unsafe.Pointer, e Uint, f uintpt
3539
//go:wasmimport modulename invalidparam
3640
func invalidparam(a [4]uint32, b []byte, c struct{ a int }, d chan struct{}, e func(), f int, g uint, h [8]int)
3741

42+
// ERROR: //go:wasmimport modulename invalidparam_no_hostlayout: unsupported parameter type *struct{int}
43+
// ERROR: //go:wasmimport modulename invalidparam_no_hostlayout: unsupported parameter type *struct{string}
44+
//
45+
//go:wasmimport modulename invalidparam_no_hostlayout
46+
func invalidparam_no_hostlayout(a *struct{ int }, b *struct{ string })
47+
3848
//go:wasmimport modulename validreturn_int32
3949
func validreturn_int32() int32
4050

@@ -47,6 +57,9 @@ func validreturn_ptr_string() *string
4757
//go:wasmimport modulename validreturn_ptr_struct
4858
func validreturn_ptr_struct() *S
4959

60+
//go:wasmimport modulename validreturn_ptr_struct
61+
func validreturn_ptr_empty_struct() *struct{}
62+
5063
//go:wasmimport modulename validreturn_ptr_array
5164
func validreturn_ptr_array() *[8]uint8
5265

0 commit comments

Comments
 (0)