mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-10 05:57:51 +00:00
Register function symbol in TypeDeterminer after processing body.
This CL removes the registration of functions to after the function body has been processed. This allows us to catch recursive calls where the function calls itself. Prior to this we'd find the called function and, if the function was an entry point, end up in a loop trying to walk all the callers. With this change, the function is not found when we do the lookup and we exit as expected. Bug: tint:258 Change-Id: Ie0173207b788e87de39867a5aa41e8cc13ec33de Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42520 Commit-Queue: dan sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com> Auto-Submit: dan sinclair <dsinclair@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
80cb20de7c
commit
f8fa6cf43c
@@ -175,45 +175,6 @@ TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) {
|
||||
EXPECT_EQ(v.error(), "12:34 v-0016: function names must be unique 'func'");
|
||||
}
|
||||
|
||||
TEST_F(ValidateFunctionTest, RecursionIsNotAllowed_Fail) {
|
||||
// fn func() -> void {func(); return; }
|
||||
ast::ExpressionList call_params;
|
||||
auto* call_expr = create<ast::CallExpression>(
|
||||
Source{Source::Location{12, 34}}, Expr("func"), call_params);
|
||||
|
||||
Func("func", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::CallStatement>(call_expr),
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
EXPECT_FALSE(v.Validate()) << v.error();
|
||||
EXPECT_EQ(v.error(), "12:34 v-0004: recursion is not allowed: 'func'");
|
||||
}
|
||||
|
||||
TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) {
|
||||
// fn func() -> i32 {var a: i32 = func(); return 2; }
|
||||
ast::ExpressionList call_params;
|
||||
auto* call_expr = create<ast::CallExpression>(
|
||||
Source{Source::Location{12, 34}}, Expr("func"), call_params);
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, call_expr);
|
||||
|
||||
Func("func", ast::VariableList{}, ty.i32(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(Expr(2)),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
EXPECT_FALSE(v.Validate()) << v.error();
|
||||
EXPECT_EQ(v.error(), "12:34 v-0004: recursion is not allowed: 'func'");
|
||||
}
|
||||
|
||||
TEST_F(ValidateFunctionTest, Function_WithPipelineStage_NotVoid_Fail) {
|
||||
// [[stage(vertex)]]
|
||||
// fn vtx_main() -> i32 { return 0; }
|
||||
|
||||
Reference in New Issue
Block a user