summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2024-08-14 15:03:48 -0400
committerGitHub <noreply@github.com>2024-08-14 12:03:48 -0700
commitcde2a52fc6d679d53d1c5b72b081992d53e01c6b (patch)
tree44d8fc7fc4d41d1d991ebcc45d017aa0f3076839
parentbcb83fd68710daf1f5ddd8252d0a0a4557494ca7 (diff)
downloadbinaryen-cde2a52fc6d679d53d1c5b72b081992d53e01c6b.tar.gz
binaryen-cde2a52fc6d679d53d1c5b72b081992d53e01c6b.tar.bz2
binaryen-cde2a52fc6d679d53d1c5b72b081992d53e01c6b.zip
Heap type `none` requires GC (#6840)
Since reference types only introduced function and extern references, all of the types in the `any` hierarchy require GC, including `none`. Fixes #6839.
-rw-r--r--src/wasm/wasm-type.cpp2
-rw-r--r--test/lit/binary/strings-nogc.test3
-rw-r--r--test/lit/validation/nullref-no-gc.wast11
-rw-r--r--test/lit/validation/shared-null.wast2
4 files changed, 13 insertions, 5 deletions
diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp
index 011c51e7b..34299a9a1 100644
--- a/src/wasm/wasm-type.cpp
+++ b/src/wasm/wasm-type.cpp
@@ -1496,12 +1496,12 @@ FeatureSet HeapType::getFeatures() const {
case HeapType::i31:
case HeapType::struct_:
case HeapType::array:
+ case HeapType::none:
feats |= FeatureSet::ReferenceTypes | FeatureSet::GC;
return;
case HeapType::string:
feats |= FeatureSet::ReferenceTypes | FeatureSet::Strings;
return;
- case HeapType::none:
case HeapType::noext:
case HeapType::nofunc:
// Technically introduced in GC, but used internally as part of
diff --git a/test/lit/binary/strings-nogc.test b/test/lit/binary/strings-nogc.test
index 7aa21d750..23fb489a3 100644
--- a/test/lit/binary/strings-nogc.test
+++ b/test/lit/binary/strings-nogc.test
@@ -5,8 +5,5 @@
(module
(func $0
(local $0 stringref)
- (local.set $0
- (ref.null none)
- )
)
)
diff --git a/test/lit/validation/nullref-no-gc.wast b/test/lit/validation/nullref-no-gc.wast
new file mode 100644
index 000000000..27560b3ff
--- /dev/null
+++ b/test/lit/validation/nullref-no-gc.wast
@@ -0,0 +1,11 @@
+;; Test that nullref without GC is a validation error.
+
+;; RUN: not wasm-opt %s -all --disable-gc 2>&1 | filecheck %s
+
+;; CHECK: all used types should be allowed
+
+(module
+ (func $test
+ (local nullref)
+ )
+)
diff --git a/test/lit/validation/shared-null.wast b/test/lit/validation/shared-null.wast
index 1c34873bb..0e491dd90 100644
--- a/test/lit/validation/shared-null.wast
+++ b/test/lit/validation/shared-null.wast
@@ -4,7 +4,7 @@
;; RUN: wasm-opt %s --enable-reference-types --enable-gc --enable-shared-everything -o - -S | filecheck %s --check-prefix SHARED
;; NO-SHARED: ref.null requires additional features
-;; NO-SHARED: [--enable-reference-types --enable-shared-everything]
+;; NO-SHARED: [--enable-reference-types --enable-gc --enable-shared-everything]
;; SHARED: (ref.null (shared none))
(module