resolver: Fix build. Enum member was renamed.

Change-Id: Iecbdd554ad60160df04be4bf3581387cb5639e6c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57420
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2021-07-08 15:12:36 +00:00
parent 70a3fa1ee9
commit 08b0ab9b92
1 changed files with 92 additions and 93 deletions

View File

@ -1197,9 +1197,10 @@ bool Resolver::ValidateFunction(const ast::Function* func,
(IsValidationEnabled( (IsValidationEnabled(
info->declaration->decorations(), info->declaration->decorations(),
ast::DisabledValidation::kEntryPointParameter) && ast::DisabledValidation::kEntryPointParameter) &&
IsValidationEnabled(info->declaration->decorations(), IsValidationEnabled(
ast::DisabledValidation:: info->declaration->decorations(),
kIgnoreAtomicFunctionParameter))) { ast::DisabledValidation::
kIgnoreConstructibleFunctionParameter))) {
AddError("decoration is not valid for entry point return types", AddError("decoration is not valid for entry point return types",
deco->source()); deco->source());
return false; return false;
@ -1231,103 +1232,101 @@ bool Resolver::ValidateEntryPoint(const ast::Function* func,
}; };
// Inner lambda that is applied to a type and all of its members. // Inner lambda that is applied to a type and all of its members.
auto validate_entry_point_decorations_inner = auto validate_entry_point_decorations_inner = [&](const ast::DecorationList&
[&](const ast::DecorationList& decos, sem::Type* ty, Source source, decos,
ParamOrRetType param_or_ret, bool is_struct_member) { sem::Type* ty,
// Scan decorations for pipeline IO attributes. Source source,
// Check for overlap with attributes that have been seen previously. ParamOrRetType param_or_ret,
ast::Decoration* pipeline_io_attribute = nullptr; bool is_struct_member) {
for (auto* deco : decos) { // Scan decorations for pipeline IO attributes.
if (auto* builtin = deco->As<ast::BuiltinDecoration>()) { // Check for overlap with attributes that have been seen previously.
if (pipeline_io_attribute) { ast::Decoration* pipeline_io_attribute = nullptr;
AddError("multiple entry point IO attributes", deco->source()); for (auto* deco : decos) {
AddNote( if (auto* builtin = deco->As<ast::BuiltinDecoration>()) {
"previously consumed " + deco_to_str(pipeline_io_attribute), if (pipeline_io_attribute) {
AddError("multiple entry point IO attributes", deco->source());
AddNote("previously consumed " + deco_to_str(pipeline_io_attribute),
pipeline_io_attribute->source()); pipeline_io_attribute->source());
return false; return false;
} }
pipeline_io_attribute = deco; pipeline_io_attribute = deco;
if (builtins.count(builtin->value())) { if (builtins.count(builtin->value())) {
AddError( AddError(deco_to_str(builtin) +
deco_to_str(builtin) + " attribute appears multiple times as pipeline " +
" attribute appears multiple times as pipeline " + (param_or_ret == ParamOrRetType::kParameter ? "input"
(param_or_ret == ParamOrRetType::kParameter ? "input" : "output"),
: "output"), func->source());
func->source()); return false;
return false; }
} builtins.emplace(builtin->value());
builtins.emplace(builtin->value());
if (!ValidateBuiltinDecoration(builtin, ty, if (!ValidateBuiltinDecoration(
/* is_input */ param_or_ret == builtin, ty,
ParamOrRetType::kParameter)) { /* is_input */ param_or_ret == ParamOrRetType::kParameter)) {
return false; return false;
}
} else if (auto* location = deco->As<ast::LocationDecoration>()) {
if (pipeline_io_attribute) {
AddError("multiple entry point IO attributes", deco->source());
AddNote(
"previously consumed " + deco_to_str(pipeline_io_attribute),
pipeline_io_attribute->source());
return false;
}
pipeline_io_attribute = deco;
if (locations.count(location->value())) {
AddError(
deco_to_str(location) +
" attribute appears multiple times as pipeline " +
(param_or_ret == ParamOrRetType::kParameter ? "input"
: "output"),
func->source());
return false;
}
locations.emplace(location->value());
}
} }
// Check that we saw a pipeline IO attribute iff we need one. } else if (auto* location = deco->As<ast::LocationDecoration>()) {
if (ty->Is<sem::Struct>()) { if (pipeline_io_attribute) {
if (pipeline_io_attribute) { AddError("multiple entry point IO attributes", deco->source());
AddError( AddNote("previously consumed " + deco_to_str(pipeline_io_attribute),
"entry point IO attributes must not be used on structure " + pipeline_io_attribute->source());
std::string(param_or_ret == ParamOrRetType::kParameter return false;
? "parameters"
: "return types"),
pipeline_io_attribute->source());
return false;
}
} else if (IsValidationEnabled(
decos, ast::DisabledValidation::kEntryPointParameter)) {
if (!pipeline_io_attribute) {
std::string err = "missing entry point IO attribute";
if (!is_struct_member) {
err += (param_or_ret == ParamOrRetType::kParameter
? " on parameter"
: " on return type");
}
AddError(err, source);
return false;
}
// Check that all user defined attributes are numeric scalars, vectors
// of numeric scalars.
// Testing for being a struct is handled by the if portion above.
if (!pipeline_io_attribute->Is<ast::BuiltinDecoration>()) {
if (!ty->is_numeric_scalar_or_vector()) {
AddError(
"User defined entry point IO types must be a numeric scalar, "
"a numeric vector, or a structure",
source);
return false;
}
}
} }
pipeline_io_attribute = deco;
return true; if (locations.count(location->value())) {
}; AddError(deco_to_str(location) +
" attribute appears multiple times as pipeline " +
(param_or_ret == ParamOrRetType::kParameter ? "input"
: "output"),
func->source());
return false;
}
locations.emplace(location->value());
}
}
// Check that we saw a pipeline IO attribute iff we need one.
if (ty->Is<sem::Struct>()) {
if (pipeline_io_attribute) {
AddError("entry point IO attributes must not be used on structure " +
std::string(param_or_ret == ParamOrRetType::kParameter
? "parameters"
: "return types"),
pipeline_io_attribute->source());
return false;
}
} else if (IsValidationEnabled(
decos, ast::DisabledValidation::kEntryPointParameter)) {
if (!pipeline_io_attribute) {
std::string err = "missing entry point IO attribute";
if (!is_struct_member) {
err +=
(param_or_ret == ParamOrRetType::kParameter ? " on parameter"
: " on return type");
}
AddError(err, source);
return false;
}
// Check that all user defined attributes are numeric scalars, vectors
// of numeric scalars.
// Testing for being a struct is handled by the if portion above.
if (!pipeline_io_attribute->Is<ast::BuiltinDecoration>()) {
if (!ty->is_numeric_scalar_or_vector()) {
AddError(
"User defined entry point IO types must be a numeric scalar, "
"a numeric vector, or a structure",
source);
return false;
}
}
}
return true;
};
// Outer lambda for validating the entry point decorations for a type. // Outer lambda for validating the entry point decorations for a type.
auto validate_entry_point_decorations = [&](const ast::DecorationList& decos, auto validate_entry_point_decorations = [&](const ast::DecorationList& decos,