Fix Validator regression reporting param not declared
This regression was accidentally introduced by my CL: https://dawn-review.googlesource.com/c/tint/+/45382 I had removed too much of ValidatorImpl::ValidateFunction, including its pushing of function parameters to the variable stack. As a result,, any function parameters referenced by a function would fail the Validator. This CL restores this bit, and adds a test for this case. Bug: tint:642 Change-Id: I839057e73cabfb11631571ce806dec09f5d9f966 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45500 Auto-Submit: Antonio Maiorano <amaiorano@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
00e823ec04
commit
4daddd1759
src/validator
|
@ -173,7 +173,6 @@ TEST_F(ValidateFunctionTest,
|
|||
"return type, returned '__u32', expected '__alias_tint_symbol_1__f32'");
|
||||
}
|
||||
|
||||
|
||||
TEST_F(ValidateFunctionTest, PipelineStage_MustBeUnique_Fail) {
|
||||
// [[stage(fragment)]]
|
||||
// [[stage(vertex)]]
|
||||
|
@ -229,5 +228,23 @@ TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Fail) {
|
|||
"be present");
|
||||
}
|
||||
|
||||
TEST_F(ValidateFunctionTest, FunctionVarInitWithParam) {
|
||||
// fn foo(bar : f32) -> void{
|
||||
// var baz : f32 = bar;
|
||||
// }
|
||||
|
||||
auto* bar = Var("bar", ty.f32(), ast::StorageClass::kFunction);
|
||||
auto* baz = Var("baz", ty.f32(), ast::StorageClass::kFunction, Expr("bar"));
|
||||
|
||||
Func("foo", ast::VariableList{bar}, ty.void_(), ast::StatementList{Decl(baz)},
|
||||
ast::DecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
EXPECT_TRUE(v.Validate()) << v.error();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace tint
|
||||
|
|
|
@ -170,9 +170,15 @@ bool ValidatorImpl::ValidateEntryPoint(const ast::FunctionList& funcs) {
|
|||
bool ValidatorImpl::ValidateFunction(const ast::Function* func) {
|
||||
// TODO(amaiorano): Remove ValidateFunction once we've moved all the statement
|
||||
// validation to Resovler
|
||||
|
||||
variable_stack_.push_scope();
|
||||
for (auto* param : func->params()) {
|
||||
variable_stack_.set(param->symbol(), param);
|
||||
}
|
||||
if (!ValidateStatements(func->body())) {
|
||||
return false;
|
||||
}
|
||||
variable_stack_.pop_scope();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue