mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-06 21:25:58 +00:00
[validation] validate if entry point functions return void
This CL validates following validation rule: v-0024: Entry point functions return void Bug: tint: 6 Change-Id: I420781008016af110cb0d3d65fc018a1301efeae Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27120 Commit-Queue: David Neto <dneto@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
1026fe3d27
commit
e871e48df0
@ -286,7 +286,7 @@ TEST_F(ValidateFunctionTest, EntryPointFunctionExist_Pass) {
|
|||||||
EXPECT_TRUE(v.Validate(mod())) << v.error();
|
EXPECT_TRUE(v.Validate(mod())) << v.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ValidateFunctionTest, DISABLED_EntryPointFunctionNotVoid_Fail) {
|
TEST_F(ValidateFunctionTest, EntryPointFunctionNotVoid_Fail) {
|
||||||
// entry_point vertex as "main" = vtx_main
|
// entry_point vertex as "main" = vtx_main
|
||||||
// fn vtx_main() -> i32 { return 0; }
|
// fn vtx_main() -> i32 { return 0; }
|
||||||
ast::type::I32Type i32;
|
ast::type::I32Type i32;
|
||||||
@ -301,7 +301,7 @@ TEST_F(ValidateFunctionTest, DISABLED_EntryPointFunctionNotVoid_Fail) {
|
|||||||
func->set_body(std::move(body));
|
func->set_body(std::move(body));
|
||||||
|
|
||||||
auto entry_point = std::make_unique<ast::EntryPoint>(
|
auto entry_point = std::make_unique<ast::EntryPoint>(
|
||||||
ast::PipelineStage::kVertex, "main", "vtx_main");
|
Source{12, 34}, ast::PipelineStage::kVertex, "main", "vtx_main");
|
||||||
|
|
||||||
mod()->AddFunction(std::move(func));
|
mod()->AddFunction(std::move(func));
|
||||||
mod()->AddEntryPoint(std::move(entry_point));
|
mod()->AddEntryPoint(std::move(entry_point));
|
||||||
|
@ -68,6 +68,14 @@ bool ValidatorImpl::ValidateEntryPoints(const ast::EntryPointList& eps) {
|
|||||||
ep_ptr->function_name() + "'");
|
ep_ptr->function_name() + "'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
ast::Function* func;
|
||||||
|
function_stack_.get(ep_ptr->function_name(), &func);
|
||||||
|
if (!func->return_type()->IsVoid()) {
|
||||||
|
set_error(ep_ptr->source(),
|
||||||
|
"v-0024: Entry point function must return void: '" +
|
||||||
|
ep_ptr->function_name() + "'");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user