Validate that runtime arrays aren't used as parameters

Remove the logic around `arrayLength()` being passed anything but a member accessor. Runtime arrays types cannot be used for variables nor parameters.

Add validator logic and test for runtime array parameters.

Adjust the validator error message so it doesn't include the field / variable name. This read weird, and the same information is already provided by the source.

Bug: tint:266
Bug: tint:252
Change-Id: Iecedb0524e10a67b4f8ad15635d67fe61e9d69d9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36420
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2021-01-05 18:20:40 +00:00
committed by Commit Bot service account
parent 938ff5f482
commit ca2c1ed370
5 changed files with 74 additions and 56 deletions

View File

@@ -83,6 +83,10 @@ class ValidatorImpl {
/// @param func the function to check
/// @returns true if the validation was successful
bool ValidateFunction(const ast::Function* func);
/// Validates a function parameter
/// @param param the function parameter to check
/// @returns true if the validation was successful
bool ValidateParameter(const ast::Variable* param);
/// Validates a block of statements
/// @param block the statements to check
/// @returns true if the validation was successful