compiler: disallow most types in //go:wasmimport

This is for compatibility with upstream Go.
See https://github.com/golang/go/issues/59149 for more context.
This commit is contained in:
Ayke van Laethem
2023-05-19 15:34:05 +02:00
committed by Ron Evans
parent 41e787d504
commit b08ff17f6b
4 changed files with 101 additions and 14 deletions
+42
View File
@@ -1 +1,43 @@
package main
import "unsafe"
//go:wasmimport modulename empty
func empty()
// ERROR: can only use //go:wasmimport on declarations
//
//go:wasmimport modulename implementation
func implementation() {
}
type Uint uint32
//go:wasmimport modulename validparam
func validparam(a int32, b uint64, c float64, d unsafe.Pointer, e Uint)
// ERROR: //go:wasmimport modulename invalidparam: unsupported parameter type int
// ERROR: //go:wasmimport modulename invalidparam: unsupported parameter type string
// ERROR: //go:wasmimport modulename invalidparam: unsupported parameter type []byte
// ERROR: //go:wasmimport modulename invalidparam: unsupported parameter type *int32
//
//go:wasmimport modulename invalidparam
func invalidparam(a int, b string, c []byte, d *int32)
//go:wasmimport modulename validreturn
func validreturn() int32
// ERROR: //go:wasmimport modulename manyreturns: too many return values
//
//go:wasmimport modulename manyreturns
func manyreturns() (int32, int32)
// ERROR: //go:wasmimport modulename invalidreturn: unsupported result type int
//
//go:wasmimport modulename invalidreturn
func invalidreturn() int
// ERROR: //go:wasmimport modulename invalidUnsafePointerReturn: unsupported result type unsafe.Pointer
//
//go:wasmimport modulename invalidUnsafePointerReturn
func invalidUnsafePointerReturn() unsafe.Pointer
-4
View File
@@ -62,10 +62,6 @@ func exportedFunctionInSection() {
//go:wasmimport modulename import1
func declaredImport()
//go:wasmimport modulename import2
func definedImport() {
}
// This function should not: it's only a declaration and not a definition.
//
//go:section .special_function_section
-6
View File
@@ -62,12 +62,6 @@ entry:
declare void @main.declaredImport() #7
; Function Attrs: nounwind
define hidden void @main.definedImport(ptr %context) unnamed_addr #2 {
entry:
ret void
}
declare void @main.undefinedFunctionNotInSection(ptr) #1
attributes #0 = { allockind("alloc,zeroed") allocsize(0) "alloc-family"="runtime.alloc" "target-features"="+bulk-memory,+nontrapping-fptoint,+sign-ext" }