Validate sign of RHS matches LHS for scalar variable declarations

Statements like `var u : u32 = 0;` should fail because '0' is a signed
integer being used to initialize an unsigned variable.

Added test.

Bug: tint:79
Change-Id: I34f6d21b4355167f49f9a8b5d4ed34a808823185
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42702
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Antonio Maiorano
2021-02-26 18:25:56 +00:00
committed by Commit Bot service account
parent e5c105d40a
commit 6ce2edfa1f
5 changed files with 78 additions and 2 deletions

View File

@@ -792,7 +792,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
// func1 { var a : f32 = 3.0; return; }
auto* var0 = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2.0f));
auto* var1 = Var("a", ty.void_(), ast::StorageClass::kNone, Expr(1.0f));
auto* var1 = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(1.0f));
Func("func0", ast::VariableList{}, ty.void_(),
ast::StatementList{