validation: fix error msg: textureSample*() offset must be a const_expr

Bug: tint:1016
Change-Id: I631ac820f3174ec7ad12e51396b7584df55b27f1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59001
Auto-Submit: Sarah Mashayekhi <sarahmashay@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
Sarah 2021-07-21 03:34:34 +00:00 committed by Sarah Mashayekhi
parent 0c7332b2ba
commit 36b49e8834
2 changed files with 8 additions and 12 deletions

View File

@ -223,8 +223,7 @@ TEST_P(IntrinsicTextureSamplerValidationTest, GlobalConst) {
EXPECT_FALSE(r()->Resolve()); EXPECT_FALSE(r()->Resolve());
std::stringstream err; std::stringstream err;
err << "12:34 error: '" << param.function err << "12:34 error: '" << param.function
<< "' offset parameter must be provided as" << "' offset parameter must be a const_expression";
<< " a literal or const_expr expression";
EXPECT_EQ(r()->error(), err.str()); EXPECT_EQ(r()->error(), err.str());
} }
@ -253,8 +252,7 @@ TEST_P(IntrinsicTextureSamplerValidationTest, ScalarConst) {
EXPECT_FALSE(r()->Resolve()); EXPECT_FALSE(r()->Resolve());
std::stringstream err; std::stringstream err;
err << "12:34 error: '" << param.function err << "12:34 error: '" << param.function
<< "' offset parameter must be provided as" << "' offset parameter must be a const_expression";
<< " a literal or const_expr expression";
EXPECT_EQ(r()->error(), err.str()); EXPECT_EQ(r()->error(), err.str());
} }

View File

@ -2479,9 +2479,8 @@ bool Resolver::ValidateTextureIntrinsicFunction(
if (param->Is<ast::TypeConstructorExpression>()) { if (param->Is<ast::TypeConstructorExpression>()) {
auto values = ConstantValueOf(param); auto values = ConstantValueOf(param);
if (!values.IsValid()) { if (!values.IsValid()) {
AddError("'" + func_name + AddError(
"' offset parameter must be provided as a literal or " "'" + func_name + "' offset parameter must be a const_expression",
"const_expr expression",
param->source()); param->source());
return false; return false;
} }
@ -2503,9 +2502,8 @@ bool Resolver::ValidateTextureIntrinsicFunction(
} }
} }
} else { } else {
AddError("'" + func_name + AddError(
"' offset parameter must be provided as a literal or " "'" + func_name + "' offset parameter must be a const_expression",
"const_expr expression",
param->source()); param->source());
return false; return false;
} }