From f70065f6222776f60738099b1c1319c9fbc36627 Mon Sep 17 00:00:00 2001 From: Sarah Mashayekhi Date: Mon, 24 Aug 2020 16:03:36 +0000 Subject: [PATCH] [validation] Validate if entry point functions accept parameters Bug: tint: 6 Change-Id: I7e9f50759e65ed6ef3dc25a6c004bec3dfbd4648 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27122 Commit-Queue: Sarah Mashayekhi Reviewed-by: dan sinclair --- src/validator_function_test.cc | 2 +- src/validator_impl.cc | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/validator_function_test.cc b/src/validator_function_test.cc index 70684d1c41..e8e4eee5f0 100644 --- a/src/validator_function_test.cc +++ b/src/validator_function_test.cc @@ -312,7 +312,7 @@ TEST_F(ValidateFunctionTest, EntryPointFunctionNotVoid_Fail) { "12:34: v-0024: Entry point function must return void: 'vtx_main'"); } -TEST_F(ValidateFunctionTest, DISABLED_EntryPointFunctionWithParams_Fail) { +TEST_F(ValidateFunctionTest, EntryPointFunctionWithParams_Fail) { // entry_point vertex as "func" = vtx_func // fn vtx_func(a : i32) -> void { return; } ast::type::I32Type i32; diff --git a/src/validator_impl.cc b/src/validator_impl.cc index 9f36feb3a7..48fd7d26e4 100644 --- a/src/validator_impl.cc +++ b/src/validator_impl.cc @@ -76,6 +76,12 @@ bool ValidatorImpl::ValidateEntryPoints(const ast::EntryPointList& eps) { ep_ptr->function_name() + "'"); return false; } + if (func->params().size() != 0) { + set_error(ep_ptr->source(), + "v-0023: Entry point function must accept no parameters: '" + + ep_ptr->function_name() + "'"); + return false; + } } return true; }