summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2019-10-21 09:20:11 -0700
committerGitHub <noreply@github.com>2019-10-21 09:20:11 -0700
commit73f141d49a8759993e0a79c3a0e86dd23784378c (patch)
tree321809077736da909b45b982eb22dea14e092080 /src
parent03816aa9c193bf8076de0d5d7a11941f60ff3353 (diff)
downloadwabt-73f141d49a8759993e0a79c3a0e86dd23784378c.tar.gz
wabt-73f141d49a8759993e0a79c3a0e86dd23784378c.tar.bz2
wabt-73f141d49a8759993e0a79c3a0e86dd23784378c.zip
Check for redefinitions of elem segments (#1193)
Fixes: #1187
Diffstat (limited to 'src')
-rw-r--r--src/resolve-names.cc1
-rw-r--r--src/wast-parser.cc14
2 files changed, 12 insertions, 3 deletions
diff --git a/src/resolve-names.cc b/src/resolve-names.cc
index 1bcc52e6..0e3c70e1 100644
--- a/src/resolve-names.cc
+++ b/src/resolve-names.cc
@@ -461,6 +461,7 @@ void NameResolver::VisitDataSegment(DataSegment* segment) {
Result NameResolver::VisitModule(Module* module) {
current_module_ = module;
+ CheckDuplicateBindings(&module->elem_segment_bindings, "elem");
CheckDuplicateBindings(&module->func_bindings, "function");
CheckDuplicateBindings(&module->global_bindings, "global");
CheckDuplicateBindings(&module->func_type_bindings, "function type");
diff --git a/src/wast-parser.cc b/src/wast-parser.cc
index 517b70bc..ca21584f 100644
--- a/src/wast-parser.cc
+++ b/src/wast-parser.cc
@@ -932,9 +932,17 @@ Result WastParser::ParseElemModuleField(Module* module) {
EXPECT(Lpar);
Location loc = GetLocation();
EXPECT(Elem);
- std::string name;
- ParseBindVarOpt(&name);
- auto field = MakeUnique<ElemSegmentModuleField>(loc, name);
+ std::string segment_name;
+ ParseBindVarOpt(&segment_name);
+ // With MVP text format the name here was intended to refer to the table
+ // that the elem segment was part of, but we never did anything with this name
+ // since there was only one table anyway.
+ // With bulk-memory enabled this introduces a new name for the particualr
+ // elem segment.
+ if (!options_->features.bulk_memory_enabled()) {
+ segment_name = "";
+ }
+ auto field = MakeUnique<ElemSegmentModuleField>(loc, segment_name);
if (ParseRefTypeOpt(&field->elem_segment.elem_type)) {
field->elem_segment.passive = true;