mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 23:56:16 +00:00
ast: Remove statement constructors that don't take a Source
Parsers need fixing up. Bug: tint:396 Bug: tint:390 Change-Id: I137f1017ca56125cf3d52ecbef2ff46d0574338b Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35161 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
1ff59cd0e2
commit
bbefff63a3
@@ -57,13 +57,14 @@ TEST_F(ValidateControlBlockTest, SwitchSelectorExpressionNoneIntegerType_Fail) {
|
||||
auto* cond = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a");
|
||||
ast::CaseSelectorList default_csl;
|
||||
auto* block_default = create<ast::BlockStatement>();
|
||||
auto* block_default = create<ast::BlockStatement>(Source{});
|
||||
ast::CaseStatementList body;
|
||||
body.push_back(create<ast::CaseStatement>(default_csl, block_default));
|
||||
body.push_back(
|
||||
create<ast::CaseStatement>(Source{}, default_csl, block_default));
|
||||
|
||||
auto* block = create<ast::BlockStatement>();
|
||||
block->append(create<ast::VariableDeclStatement>(var));
|
||||
block->append(create<ast::SwitchStatement>(cond, body));
|
||||
auto* block = create<ast::BlockStatement>(Source{});
|
||||
block->append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
block->append(create<ast::SwitchStatement>(Source{}, cond, body));
|
||||
|
||||
EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error();
|
||||
EXPECT_FALSE(v()->ValidateStatements(block));
|
||||
@@ -94,11 +95,11 @@ TEST_F(ValidateControlBlockTest, SwitchWithoutDefault_Fail) {
|
||||
ast::CaseSelectorList csl;
|
||||
csl.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
ast::CaseStatementList body;
|
||||
body.push_back(
|
||||
create<ast::CaseStatement>(csl, create<ast::BlockStatement>()));
|
||||
body.push_back(create<ast::CaseStatement>(
|
||||
Source{}, csl, create<ast::BlockStatement>(Source{})));
|
||||
|
||||
auto* block = create<ast::BlockStatement>();
|
||||
block->append(create<ast::VariableDeclStatement>(var));
|
||||
auto* block = create<ast::BlockStatement>(Source{});
|
||||
block->append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
block->append(create<ast::SwitchStatement>(Source{Source::Location{12, 34}},
|
||||
cond, body));
|
||||
|
||||
@@ -133,22 +134,23 @@ TEST_F(ValidateControlBlockTest, SwitchWithTwoDefault_Fail) {
|
||||
Source{}, mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList default_csl_1;
|
||||
auto* block_default_1 = create<ast::BlockStatement>();
|
||||
auto* block_default_1 = create<ast::BlockStatement>(Source{});
|
||||
switch_body.push_back(
|
||||
create<ast::CaseStatement>(default_csl_1, block_default_1));
|
||||
create<ast::CaseStatement>(Source{}, default_csl_1, block_default_1));
|
||||
|
||||
ast::CaseSelectorList csl_case_1;
|
||||
csl_case_1.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
auto* block_case_1 = create<ast::BlockStatement>();
|
||||
switch_body.push_back(create<ast::CaseStatement>(csl_case_1, block_case_1));
|
||||
auto* block_case_1 = create<ast::BlockStatement>(Source{});
|
||||
switch_body.push_back(
|
||||
create<ast::CaseStatement>(Source{}, csl_case_1, block_case_1));
|
||||
|
||||
ast::CaseSelectorList default_csl_2;
|
||||
auto* block_default_2 = create<ast::BlockStatement>();
|
||||
auto* block_default_2 = create<ast::BlockStatement>(Source{});
|
||||
switch_body.push_back(
|
||||
create<ast::CaseStatement>(default_csl_2, block_default_2));
|
||||
create<ast::CaseStatement>(Source{}, default_csl_2, block_default_2));
|
||||
|
||||
auto* block = create<ast::BlockStatement>();
|
||||
block->append(create<ast::VariableDeclStatement>(var));
|
||||
auto* block = create<ast::BlockStatement>(Source{});
|
||||
block->append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
block->append(create<ast::SwitchStatement>(Source{Source::Location{12, 34}},
|
||||
cond, switch_body));
|
||||
|
||||
@@ -185,16 +187,18 @@ TEST_F(ValidateControlBlockTest,
|
||||
|
||||
ast::CaseSelectorList csl;
|
||||
csl.push_back(create<ast::UintLiteral>(Source{}, &u32, 1));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
Source{Source::Location{12, 34}}, csl, create<ast::BlockStatement>()));
|
||||
switch_body.push_back(
|
||||
create<ast::CaseStatement>(Source{Source::Location{12, 34}}, csl,
|
||||
create<ast::BlockStatement>(Source{})));
|
||||
|
||||
ast::CaseSelectorList default_csl;
|
||||
auto* block_default = create<ast::BlockStatement>();
|
||||
switch_body.push_back(create<ast::CaseStatement>(default_csl, block_default));
|
||||
auto* block_default = create<ast::BlockStatement>(Source{});
|
||||
switch_body.push_back(
|
||||
create<ast::CaseStatement>(Source{}, default_csl, block_default));
|
||||
|
||||
auto* block = create<ast::BlockStatement>();
|
||||
block->append(create<ast::VariableDeclStatement>(var));
|
||||
block->append(create<ast::SwitchStatement>(cond, switch_body));
|
||||
auto* block = create<ast::BlockStatement>(Source{});
|
||||
block->append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
block->append(create<ast::SwitchStatement>(Source{}, cond, switch_body));
|
||||
|
||||
EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error();
|
||||
EXPECT_FALSE(v()->ValidateStatements(block));
|
||||
@@ -229,16 +233,18 @@ TEST_F(ValidateControlBlockTest,
|
||||
|
||||
ast::CaseSelectorList csl;
|
||||
csl.push_back(create<ast::SintLiteral>(Source{}, &i32, -1));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
Source{Source::Location{12, 34}}, csl, create<ast::BlockStatement>()));
|
||||
switch_body.push_back(
|
||||
create<ast::CaseStatement>(Source{Source::Location{12, 34}}, csl,
|
||||
create<ast::BlockStatement>(Source{})));
|
||||
|
||||
ast::CaseSelectorList default_csl;
|
||||
auto* block_default = create<ast::BlockStatement>();
|
||||
switch_body.push_back(create<ast::CaseStatement>(default_csl, block_default));
|
||||
auto* block_default = create<ast::BlockStatement>(Source{});
|
||||
switch_body.push_back(
|
||||
create<ast::CaseStatement>(Source{}, default_csl, block_default));
|
||||
|
||||
auto* block = create<ast::BlockStatement>();
|
||||
block->append(create<ast::VariableDeclStatement>(var));
|
||||
block->append(create<ast::SwitchStatement>(cond, switch_body));
|
||||
auto* block = create<ast::BlockStatement>(Source{});
|
||||
block->append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
block->append(create<ast::SwitchStatement>(Source{}, cond, switch_body));
|
||||
|
||||
EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error();
|
||||
EXPECT_FALSE(v()->ValidateStatements(block));
|
||||
@@ -272,22 +278,24 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueUint_Fail) {
|
||||
|
||||
ast::CaseSelectorList csl_1;
|
||||
csl_1.push_back(create<ast::UintLiteral>(Source{}, &u32, 0));
|
||||
switch_body.push_back(
|
||||
create<ast::CaseStatement>(csl_1, create<ast::BlockStatement>()));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
Source{}, csl_1, create<ast::BlockStatement>(Source{})));
|
||||
|
||||
ast::CaseSelectorList csl_2;
|
||||
csl_2.push_back(create<ast::UintLiteral>(Source{}, &u32, 2));
|
||||
csl_2.push_back(create<ast::UintLiteral>(Source{}, &u32, 2));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
Source{Source::Location{12, 34}}, csl_2, create<ast::BlockStatement>()));
|
||||
switch_body.push_back(
|
||||
create<ast::CaseStatement>(Source{Source::Location{12, 34}}, csl_2,
|
||||
create<ast::BlockStatement>(Source{})));
|
||||
|
||||
ast::CaseSelectorList default_csl;
|
||||
auto* block_default = create<ast::BlockStatement>();
|
||||
switch_body.push_back(create<ast::CaseStatement>(default_csl, block_default));
|
||||
auto* block_default = create<ast::BlockStatement>(Source{});
|
||||
switch_body.push_back(
|
||||
create<ast::CaseStatement>(Source{}, default_csl, block_default));
|
||||
|
||||
auto* block = create<ast::BlockStatement>();
|
||||
block->append(create<ast::VariableDeclStatement>(var));
|
||||
block->append(create<ast::SwitchStatement>(cond, switch_body));
|
||||
auto* block = create<ast::BlockStatement>(Source{});
|
||||
block->append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
block->append(create<ast::SwitchStatement>(Source{}, cond, switch_body));
|
||||
|
||||
EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error();
|
||||
EXPECT_FALSE(v()->ValidateStatements(block));
|
||||
@@ -321,24 +329,26 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueSint_Fail) {
|
||||
|
||||
ast::CaseSelectorList csl_1;
|
||||
csl_1.push_back(create<ast::SintLiteral>(Source{}, &i32, 10));
|
||||
switch_body.push_back(
|
||||
create<ast::CaseStatement>(csl_1, create<ast::BlockStatement>()));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
Source{}, csl_1, create<ast::BlockStatement>(Source{})));
|
||||
|
||||
ast::CaseSelectorList csl_2;
|
||||
csl_2.push_back(create<ast::SintLiteral>(Source{}, &i32, 0));
|
||||
csl_2.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
csl_2.push_back(create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
csl_2.push_back(create<ast::SintLiteral>(Source{}, &i32, 10));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
Source{Source::Location{12, 34}}, csl_2, create<ast::BlockStatement>()));
|
||||
switch_body.push_back(
|
||||
create<ast::CaseStatement>(Source{Source::Location{12, 34}}, csl_2,
|
||||
create<ast::BlockStatement>(Source{})));
|
||||
|
||||
ast::CaseSelectorList default_csl;
|
||||
auto* block_default = create<ast::BlockStatement>();
|
||||
switch_body.push_back(create<ast::CaseStatement>(default_csl, block_default));
|
||||
auto* block_default = create<ast::BlockStatement>(Source{});
|
||||
switch_body.push_back(
|
||||
create<ast::CaseStatement>(Source{}, default_csl, block_default));
|
||||
|
||||
auto* block = create<ast::BlockStatement>();
|
||||
block->append(create<ast::VariableDeclStatement>(var));
|
||||
block->append(create<ast::SwitchStatement>(cond, switch_body));
|
||||
auto* block = create<ast::BlockStatement>(Source{});
|
||||
block->append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
block->append(create<ast::SwitchStatement>(Source{}, cond, switch_body));
|
||||
|
||||
EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error();
|
||||
EXPECT_FALSE(v()->ValidateStatements(block));
|
||||
@@ -367,15 +377,16 @@ TEST_F(ValidateControlBlockTest, LastClauseLastStatementIsFallthrough_Fail) {
|
||||
auto* cond = create<ast::IdentifierExpression>(
|
||||
Source{}, mod()->RegisterSymbol("a"), "a");
|
||||
ast::CaseSelectorList default_csl;
|
||||
auto* block_default = create<ast::BlockStatement>();
|
||||
auto* block_default = create<ast::BlockStatement>(Source{});
|
||||
block_default->append(
|
||||
create<ast::FallthroughStatement>(Source{Source::Location{12, 34}}));
|
||||
ast::CaseStatementList body;
|
||||
body.push_back(create<ast::CaseStatement>(default_csl, block_default));
|
||||
body.push_back(
|
||||
create<ast::CaseStatement>(Source{}, default_csl, block_default));
|
||||
|
||||
auto* block = create<ast::BlockStatement>();
|
||||
block->append(create<ast::VariableDeclStatement>(var));
|
||||
block->append(create<ast::SwitchStatement>(cond, body));
|
||||
auto* block = create<ast::BlockStatement>(Source{});
|
||||
block->append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
block->append(create<ast::SwitchStatement>(Source{}, cond, body));
|
||||
|
||||
EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error();
|
||||
EXPECT_FALSE(v()->ValidateStatements(block));
|
||||
@@ -405,18 +416,18 @@ TEST_F(ValidateControlBlockTest, SwitchCase_Pass) {
|
||||
auto* cond = create<ast::IdentifierExpression>(
|
||||
Source{}, mod()->RegisterSymbol("a"), "a");
|
||||
ast::CaseSelectorList default_csl;
|
||||
auto* block_default = create<ast::BlockStatement>();
|
||||
auto* block_default = create<ast::BlockStatement>(Source{});
|
||||
ast::CaseStatementList body;
|
||||
body.push_back(create<ast::CaseStatement>(Source{Source::Location{12, 34}},
|
||||
default_csl, block_default));
|
||||
ast::CaseSelectorList case_csl;
|
||||
case_csl.push_back(create<ast::SintLiteral>(Source{}, &i32, 5));
|
||||
auto* block_case = create<ast::BlockStatement>();
|
||||
body.push_back(create<ast::CaseStatement>(case_csl, block_case));
|
||||
auto* block_case = create<ast::BlockStatement>(Source{});
|
||||
body.push_back(create<ast::CaseStatement>(Source{}, case_csl, block_case));
|
||||
|
||||
auto* block = create<ast::BlockStatement>();
|
||||
block->append(create<ast::VariableDeclStatement>(var));
|
||||
block->append(create<ast::SwitchStatement>(cond, body));
|
||||
auto* block = create<ast::BlockStatement>(Source{});
|
||||
block->append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
block->append(create<ast::SwitchStatement>(Source{}, cond, body));
|
||||
|
||||
EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error();
|
||||
EXPECT_TRUE(v()->ValidateStatements(block)) << v()->error();
|
||||
@@ -446,14 +457,14 @@ TEST_F(ValidateControlBlockTest, SwitchCaseAlias_Pass) {
|
||||
auto* cond = create<ast::IdentifierExpression>(
|
||||
Source{}, mod()->RegisterSymbol("a"), "a");
|
||||
ast::CaseSelectorList default_csl;
|
||||
auto* block_default = create<ast::BlockStatement>();
|
||||
auto* block_default = create<ast::BlockStatement>(Source{});
|
||||
ast::CaseStatementList body;
|
||||
body.push_back(create<ast::CaseStatement>(Source{Source::Location{12, 34}},
|
||||
default_csl, block_default));
|
||||
|
||||
auto* block = create<ast::BlockStatement>();
|
||||
block->append(create<ast::VariableDeclStatement>(var));
|
||||
block->append(create<ast::SwitchStatement>(cond, body));
|
||||
auto* block = create<ast::BlockStatement>(Source{});
|
||||
block->append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
block->append(create<ast::SwitchStatement>(Source{}, cond, body));
|
||||
|
||||
mod()->AddConstructedType(&my_int);
|
||||
|
||||
|
||||
@@ -52,8 +52,8 @@ TEST_F(ValidateFunctionTest, VoidFunctionEndWithoutReturnStatement_Pass) {
|
||||
|
||||
ast::VariableList params;
|
||||
ast::type::Void void_type;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
auto* func = create<ast::Function>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("func"), "func",
|
||||
params, &void_type, body,
|
||||
@@ -74,7 +74,7 @@ TEST_F(ValidateFunctionTest,
|
||||
ast::VariableList params;
|
||||
auto* func = create<ast::Function>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("func"), "func",
|
||||
params, &void_type, create<ast::BlockStatement>(),
|
||||
params, &void_type, create<ast::BlockStatement>(Source{}),
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex, Source{}),
|
||||
});
|
||||
@@ -101,8 +101,8 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatement_Fail) {
|
||||
|
||||
ast::VariableList params;
|
||||
ast::type::Void void_type;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
auto* func = create<ast::Function>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("func"), "func",
|
||||
params, &i32, body, ast::FunctionDecorationList{});
|
||||
@@ -121,7 +121,7 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatementEmptyBody_Fail) {
|
||||
ast::VariableList params;
|
||||
auto* func = create<ast::Function>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("func"), "func",
|
||||
params, &i32, create<ast::BlockStatement>(),
|
||||
params, &i32, create<ast::BlockStatement>(Source{}),
|
||||
ast::FunctionDecorationList{});
|
||||
mod()->AddFunction(func);
|
||||
|
||||
@@ -137,7 +137,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_Pass) {
|
||||
ast::type::Void void_type;
|
||||
ast::VariableList params;
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::ReturnStatement>(Source{}));
|
||||
auto* func = create<ast::Function>(
|
||||
Source{}, mod()->RegisterSymbol("func"), "func", params, &void_type, body,
|
||||
@@ -155,7 +155,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) {
|
||||
ast::type::Void void_type;
|
||||
ast::type::I32 i32;
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
auto* return_expr = create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
@@ -179,7 +179,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementTypeF32_fail) {
|
||||
ast::type::I32 i32;
|
||||
ast::type::F32 f32;
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
auto* return_expr = create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
@@ -205,7 +205,7 @@ TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) {
|
||||
ast::type::I32 i32;
|
||||
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
auto* return_expr = create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
@@ -215,7 +215,7 @@ TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) {
|
||||
params, &i32, body, ast::FunctionDecorationList{});
|
||||
|
||||
ast::VariableList params_copy;
|
||||
auto* body_copy = create<ast::BlockStatement>();
|
||||
auto* body_copy = create<ast::BlockStatement>(Source{});
|
||||
auto* return_expr_copy = create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
@@ -243,8 +243,8 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowed_Fail) {
|
||||
"func"),
|
||||
call_params);
|
||||
ast::VariableList params0;
|
||||
auto* body0 = create<ast::BlockStatement>();
|
||||
body0->append(create<ast::CallStatement>(call_expr));
|
||||
auto* body0 = create<ast::BlockStatement>(Source{});
|
||||
body0->append(create<ast::CallStatement>(Source{}, call_expr));
|
||||
body0->append(create<ast::ReturnStatement>(Source{}));
|
||||
auto* func0 = create<ast::Function>(Source{}, mod()->RegisterSymbol("func"),
|
||||
"func", params0, &f32, body0,
|
||||
@@ -275,8 +275,8 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) {
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::VariableList params0;
|
||||
auto* body0 = create<ast::BlockStatement>();
|
||||
body0->append(create<ast::VariableDeclStatement>(var));
|
||||
auto* body0 = create<ast::BlockStatement>(Source{});
|
||||
body0->append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
auto* return_expr = create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
@@ -299,7 +299,7 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_NotVoid_Fail) {
|
||||
auto* return_expr = create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 0));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::ReturnStatement>(Source{}, return_expr));
|
||||
auto* func = create<ast::Function>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("vtx_main"),
|
||||
@@ -329,7 +329,7 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_WithParams_Fail) {
|
||||
false, // is_const
|
||||
nullptr, // constructor
|
||||
ast::VariableDecorationList{})); // decorations
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::ReturnStatement>(Source{}));
|
||||
auto* func = create<ast::Function>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("vtx_func"),
|
||||
@@ -352,7 +352,7 @@ TEST_F(ValidateFunctionTest, PipelineStage_MustBeUnique_Fail) {
|
||||
// fn main() -> void { return; }
|
||||
ast::type::Void void_type;
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::ReturnStatement>(Source{}));
|
||||
auto* func = create<ast::Function>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("main"), "main",
|
||||
@@ -375,7 +375,7 @@ TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Pass) {
|
||||
// fn vtx_func() -> void { return; }
|
||||
ast::type::Void void_type;
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::ReturnStatement>(Source{}));
|
||||
auto* func = create<ast::Function>(
|
||||
Source{}, mod()->RegisterSymbol("vtx_func"), "vtx_func", params,
|
||||
@@ -393,7 +393,7 @@ TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Fail) {
|
||||
// fn vtx_func() -> void { return; }
|
||||
ast::type::Void void_type;
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::ReturnStatement>(Source{}));
|
||||
auto* func = create<ast::Function>(
|
||||
Source{}, mod()->RegisterSymbol("vtx_func"), "vtx_func", params,
|
||||
|
||||
@@ -103,7 +103,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInBlockStatement_Fail) {
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
Source{Source::Location{12, 34}}, lhs, rhs));
|
||||
|
||||
@@ -199,8 +199,8 @@ TEST_F(ValidatorTest, AssignCompatibleTypesInBlockStatement_Pass) {
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
Source{Source::Location{12, 34}}, lhs, rhs));
|
||||
|
||||
@@ -234,8 +234,8 @@ TEST_F(ValidatorTest, AssignIncompatibleTypesInBlockStatement_Fail) {
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
|
||||
|
||||
ast::BlockStatement block;
|
||||
block.append(create<ast::VariableDeclStatement>(var));
|
||||
ast::BlockStatement block(Source{});
|
||||
block.append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
block.append(create<ast::AssignmentStatement>(
|
||||
Source{Source::Location{12, 34}}, lhs, rhs));
|
||||
|
||||
@@ -339,7 +339,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) {
|
||||
Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
|
||||
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
Source{Source::Location{12, 34}}, lhs, rhs));
|
||||
|
||||
@@ -379,7 +379,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) {
|
||||
|
||||
ast::VariableList params;
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
Source{Source::Location{12, 34}}, lhs, rhs));
|
||||
body->append(create<ast::ReturnStatement>(Source{}));
|
||||
@@ -415,15 +415,15 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInnerScope_Fail) {
|
||||
ast::type::Bool bool_type;
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
|
||||
|
||||
auto* outer_body = create<ast::BlockStatement>();
|
||||
auto* outer_body = create<ast::BlockStatement>(Source{});
|
||||
outer_body->append(
|
||||
create<ast::IfStatement>(Source{}, cond, body, ast::ElseStatementList{}));
|
||||
outer_body->append(create<ast::AssignmentStatement>(
|
||||
@@ -461,12 +461,12 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) {
|
||||
ast::type::Bool bool_type;
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
Source{Source::Location{12, 34}}, lhs, rhs));
|
||||
|
||||
auto* outer_body = create<ast::BlockStatement>();
|
||||
outer_body->append(create<ast::VariableDeclStatement>(var));
|
||||
auto* outer_body = create<ast::BlockStatement>(Source{});
|
||||
outer_body->append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
outer_body->append(
|
||||
create<ast::IfStatement>(Source{}, cond, body, ast::ElseStatementList{}));
|
||||
EXPECT_TRUE(td()->DetermineStatements(outer_body)) << td()->error();
|
||||
@@ -564,8 +564,8 @@ TEST_F(ValidatorTest, AssignToConstant_Fail) {
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
Source{Source::Location{12, 34}}, lhs, rhs));
|
||||
|
||||
@@ -609,7 +609,7 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) {
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::VariableDeclStatement>(
|
||||
Source{Source::Location{12, 34}}, var));
|
||||
auto* func = create<ast::Function>(Source{}, mod()->RegisterSymbol("my_func"),
|
||||
@@ -655,8 +655,8 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) {
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
body->append(create<ast::VariableDeclStatement>(
|
||||
Source{Source::Location{12, 34}}, var_a_float));
|
||||
auto* func = create<ast::Function>(Source{}, mod()->RegisterSymbol("my_func"),
|
||||
@@ -691,8 +691,8 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) {
|
||||
ast::type::Bool bool_type;
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
|
||||
auto* var_a_float = create<ast::Variable>(
|
||||
Source{}, // source
|
||||
@@ -705,7 +705,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) {
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* outer_body = create<ast::BlockStatement>();
|
||||
auto* outer_body = create<ast::BlockStatement>(Source{});
|
||||
outer_body->append(
|
||||
create<ast::IfStatement>(Source{}, cond, body, ast::ElseStatementList{}));
|
||||
outer_body->append(create<ast::VariableDeclStatement>(
|
||||
@@ -748,12 +748,12 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) {
|
||||
ast::type::Bool bool_type;
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::VariableDeclStatement>(
|
||||
Source{Source::Location{12, 34}}, var));
|
||||
|
||||
auto* outer_body = create<ast::BlockStatement>();
|
||||
outer_body->append(create<ast::VariableDeclStatement>(var_a_float));
|
||||
auto* outer_body = create<ast::BlockStatement>(Source{});
|
||||
outer_body->append(create<ast::VariableDeclStatement>(Source{}, var_a_float));
|
||||
outer_body->append(
|
||||
create<ast::IfStatement>(Source{}, cond, body, ast::ElseStatementList{}));
|
||||
|
||||
@@ -790,7 +790,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::VariableList params0;
|
||||
auto* body0 = create<ast::BlockStatement>();
|
||||
auto* body0 = create<ast::BlockStatement>(Source{});
|
||||
body0->append(create<ast::VariableDeclStatement>(
|
||||
Source{Source::Location{12, 34}}, var0));
|
||||
body0->append(create<ast::ReturnStatement>(Source{}));
|
||||
@@ -799,7 +799,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
ast::VariableList params1;
|
||||
auto* body1 = create<ast::BlockStatement>();
|
||||
auto* body1 = create<ast::BlockStatement>(Source{});
|
||||
body1->append(create<ast::VariableDeclStatement>(
|
||||
Source{Source::Location{13, 34}}, var1));
|
||||
body1->append(create<ast::ReturnStatement>(Source{}));
|
||||
@@ -838,8 +838,8 @@ TEST_F(ValidatorTest, VariableDeclNoConstructor_Pass) {
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::VariableDeclStatement>(Source{}, var));
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
Source{Source::Location{12, 34}}, lhs, rhs));
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayInFunction_Fail) {
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
ast::VariableList params;
|
||||
ast::type::Void void_type;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* body = create<ast::BlockStatement>(Source{});
|
||||
body->append(create<ast::VariableDeclStatement>(
|
||||
Source{Source::Location{12, 34}}, var));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user