mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-10 05:57:51 +00:00
Have ProgramBuilder::Func() register the function
With the ast::Module::Functions(). Also remove pointless calls to td.Determine() that will automatically be done when the program is built. Change-Id: Ia7506e430b04d91d4f6b02fb6b678d0ea9912bcd Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39900 Commit-Queue: dan sinclair <dsinclair@chromium.org> Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
611f727a09
commit
42d1e097e6
@@ -41,15 +41,14 @@ TEST_F(ValidateFunctionTest, VoidFunctionEndWithoutReturnStatement_Pass) {
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* func = Func(
|
||||
Source{Source::Location{12, 34}}, "func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
AST().Functions().Add(func);
|
||||
Func(Source{Source::Location{12, 34}}, "func", ast::VariableList{},
|
||||
ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
@@ -62,13 +61,12 @@ TEST_F(ValidateFunctionTest,
|
||||
VoidFunctionEndWithoutReturnStatementEmptyBody_Pass) {
|
||||
// [[stage(vertex)]]
|
||||
// fn func -> void {}
|
||||
auto* func =
|
||||
Func(Source{Source::Location{12, 34}}, "func", ast::VariableList{},
|
||||
ty.void_(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
AST().Functions().Add(func);
|
||||
|
||||
Func(Source{Source::Location{12, 34}}, "func", ast::VariableList{},
|
||||
ty.void_(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
@@ -83,13 +81,11 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatement_Fail) {
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* func = Func(Source{Source::Location{12, 34}}, "func",
|
||||
ast::VariableList{}, ty.i32(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
AST().Functions().Add(func);
|
||||
Func(Source{Source::Location{12, 34}}, "func", ast::VariableList{}, ty.i32(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
@@ -102,10 +98,9 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatement_Fail) {
|
||||
|
||||
TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatementEmptyBody_Fail) {
|
||||
// fn func -> int {}
|
||||
auto* func =
|
||||
Func(Source{Source::Location{12, 34}}, "func", ast::VariableList{},
|
||||
ty.i32(), ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
AST().Functions().Add(func);
|
||||
|
||||
Func(Source{Source::Location{12, 34}}, "func", ast::VariableList{}, ty.i32(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
@@ -119,15 +114,14 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatementEmptyBody_Fail) {
|
||||
TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_Pass) {
|
||||
// [[stage(vertex)]]
|
||||
// fn func -> void { return; }
|
||||
auto* func =
|
||||
Func("func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
AST().Functions().Add(func);
|
||||
|
||||
Func("func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
||||
EXPECT_TRUE(td()->DetermineFunctions(AST().Functions())) << td()->error();
|
||||
|
||||
@@ -139,13 +133,12 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_Pass) {
|
||||
|
||||
TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) {
|
||||
// fn func -> void { return 2; }
|
||||
auto* func = Func("func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(
|
||||
Source{Source::Location{12, 34}}, Expr(2)),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
AST().Functions().Add(func);
|
||||
Func("func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(Source{Source::Location{12, 34}},
|
||||
Expr(2)),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
@@ -160,13 +153,12 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) {
|
||||
|
||||
TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementTypeF32_fail) {
|
||||
// fn func -> f32 { return 2; }
|
||||
auto* func = Func("func", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(
|
||||
Source{Source::Location{12, 34}}, Expr(2)),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
AST().Functions().Add(func);
|
||||
Func("func", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(Source{Source::Location{12, 34}},
|
||||
Expr(2)),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
@@ -182,21 +174,17 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementTypeF32_fail) {
|
||||
TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) {
|
||||
// fn func -> i32 { return 2; }
|
||||
// fn func -> i32 { return 2; }
|
||||
auto* func = Func("func", ast::VariableList{}, ty.i32(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(Expr(2)),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
Func("func", ast::VariableList{}, ty.i32(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(Expr(2)),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
auto* func_copy = Func(Source{Source::Location{12, 34}}, "func",
|
||||
ast::VariableList{}, ty.i32(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(Expr(2)),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
AST().Functions().Add(func);
|
||||
AST().Functions().Add(func_copy);
|
||||
Func(Source{Source::Location{12, 34}}, "func", ast::VariableList{}, ty.i32(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(Expr(2)),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
@@ -212,13 +200,12 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowed_Fail) {
|
||||
auto* call_expr = create<ast::CallExpression>(
|
||||
Source{Source::Location{12, 34}}, Expr("func"), call_params);
|
||||
|
||||
auto* func0 = Func("func", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::CallStatement>(call_expr),
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
AST().Functions().Add(func0);
|
||||
Func("func", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::CallStatement>(call_expr),
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
@@ -236,13 +223,12 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) {
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32(), call_expr,
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* func0 = Func("func", ast::VariableList{}, ty.i32(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(Expr(2)),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
AST().Functions().Add(func0);
|
||||
Func("func", ast::VariableList{}, ty.i32(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(Expr(2)),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
@@ -255,17 +241,16 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) {
|
||||
TEST_F(ValidateFunctionTest, Function_WithPipelineStage_NotVoid_Fail) {
|
||||
// [[stage(vertex)]]
|
||||
// fn vtx_main() -> i32 { return 0; }
|
||||
auto* func =
|
||||
Func(Source{Source::Location{12, 34}}, "vtx_main", ast::VariableList{},
|
||||
ty.i32(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(Expr(0)),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
||||
AST().Functions().Add(func);
|
||||
Func(Source{Source::Location{12, 34}}, "vtx_main", ast::VariableList{},
|
||||
ty.i32(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(Expr(0)),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
@@ -278,19 +263,18 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_NotVoid_Fail) {
|
||||
TEST_F(ValidateFunctionTest, Function_WithPipelineStage_WithParams_Fail) {
|
||||
// [[stage(vertex)]]
|
||||
// fn vtx_func(a : i32) -> void { return; }
|
||||
auto* func =
|
||||
Func(Source{Source::Location{12, 34}}, "vtx_func",
|
||||
ast::VariableList{Var("a", ast::StorageClass::kNone, ty.i32(),
|
||||
nullptr, ast::VariableDecorationList{})},
|
||||
ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
||||
AST().Functions().Add(func);
|
||||
Func(Source{Source::Location{12, 34}}, "vtx_func",
|
||||
ast::VariableList{Var("a", ast::StorageClass::kNone, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{})},
|
||||
ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
@@ -305,17 +289,16 @@ TEST_F(ValidateFunctionTest, PipelineStage_MustBeUnique_Fail) {
|
||||
// [[stage(fragment)]]
|
||||
// [[stage(vertex)]]
|
||||
// fn main() -> void { return; }
|
||||
auto* func = Func(
|
||||
Source{Source::Location{12, 34}}, "main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
|
||||
});
|
||||
Func(Source{Source::Location{12, 34}}, "main", ast::VariableList{},
|
||||
ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
|
||||
});
|
||||
|
||||
AST().Functions().Add(func);
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
@@ -329,15 +312,14 @@ TEST_F(ValidateFunctionTest, PipelineStage_MustBeUnique_Fail) {
|
||||
TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Pass) {
|
||||
// [[stage(vertex)]]
|
||||
// fn vtx_func() -> void { return; }
|
||||
auto* func =
|
||||
Func("vtx_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
AST().Functions().Add(func);
|
||||
|
||||
Func("vtx_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
@@ -348,12 +330,11 @@ TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Pass) {
|
||||
|
||||
TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Fail) {
|
||||
// fn vtx_func() -> void { return; }
|
||||
auto* func = Func("vtx_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
AST().Functions().Add(func);
|
||||
Func("vtx_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
|
||||
@@ -431,13 +431,12 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) {
|
||||
auto* lhs = Expr("not_global_var");
|
||||
auto* rhs = Expr(3.14f);
|
||||
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(
|
||||
Source{Source::Location{12, 34}}, lhs, rhs),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
AST().Functions().Add(func);
|
||||
Func("my_func", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Source{Source::Location{12, 34}},
|
||||
lhs, rhs),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
@@ -456,17 +455,15 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) {
|
||||
ty.f32(), Expr(2.1f),
|
||||
ast::VariableDecorationList{}));
|
||||
|
||||
auto* func = Func(
|
||||
"my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Source{Source::Location{12, 34}},
|
||||
Expr("global_var"), Expr(3.14f)),
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
AST().Functions().Add(func);
|
||||
Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Source{Source::Location{12, 34}},
|
||||
Expr("global_var"), Expr(3.14f)),
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
@@ -654,14 +651,12 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) {
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32(), Expr(2.0f),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(
|
||||
Source{Source::Location{12, 34}}, var),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
AST().Functions().Add(func);
|
||||
Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(Source{Source::Location{12, 34}},
|
||||
var),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
@@ -682,15 +677,13 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) {
|
||||
auto* var_a_float = Var("a", ast::StorageClass::kNone, ty.f32(), Expr(0.1f),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::VariableDeclStatement>(
|
||||
Source{Source::Location{12, 34}}, var_a_float),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
AST().Functions().Add(func);
|
||||
Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::VariableDeclStatement>(Source{Source::Location{12, 34}},
|
||||
var_a_float),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
@@ -818,27 +811,23 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
|
||||
auto* var1 = Var("a", ast::StorageClass::kNone, ty.void_(), Expr(1.0f),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* func0 = Func("func0", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(
|
||||
Source{Source::Location{12, 34}}, var0),
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
Func("func0", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(Source{Source::Location{12, 34}},
|
||||
var0),
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
auto* func1 =
|
||||
Func("func1", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(
|
||||
Source{Source::Location{13, 34}}, var1),
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
||||
AST().Functions().Add(func0);
|
||||
AST().Functions().Add(func1);
|
||||
Func("func1", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(Source{Source::Location{13, 34}},
|
||||
var1),
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
|
||||
@@ -168,16 +168,15 @@ TEST_F(ValidatorTypeTest, RuntimeArrayInFunction_Fail) {
|
||||
// fn func -> void { var a : array<i32>; }
|
||||
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.array<i32>());
|
||||
auto* func =
|
||||
Func("func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(
|
||||
Source{Source::Location{12, 34}}, var),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
AST().Functions().Add(func);
|
||||
|
||||
Func("func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(Source{Source::Location{12, 34}},
|
||||
var),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
@@ -197,22 +196,19 @@ TEST_F(ValidatorTypeTest, RuntimeArrayAsParameter_Fail) {
|
||||
Var(Source{Source::Location{12, 34}}, "a", ast::StorageClass::kNone,
|
||||
ty.array<i32>(), nullptr, ast::VariableDecorationList{});
|
||||
|
||||
auto* func = Func("func", ast::VariableList{param}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
AST().Functions().Add(func);
|
||||
Func("func", ast::VariableList{param}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
auto* main =
|
||||
Func("main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
AST().Functions().Add(main);
|
||||
Func("main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user