Fix issue resolving address of numeric.
This CL fixes up a clusterfuzz issue where the address of a numeric was take in a case selector leading to a nullptr. Bug: chromium:1376865 Change-Id: I3b78a17e1c47263e18d2d272ff28c2cc8be79a0e Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106540 Auto-Submit: Dan Sinclair <dsinclair@chromium.org> Reviewed-by: Antonio Maiorano <amaiorano@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
882b38a2f5
commit
481b2ed959
|
@ -3113,6 +3113,9 @@ sem::SwitchStatement* Resolver::SwitchStatement(const ast::SwitchStatement* stmt
|
|||
continue;
|
||||
}
|
||||
auto* sem_expr = Expression(sel->expr);
|
||||
if (!sem_expr) {
|
||||
return false;
|
||||
}
|
||||
types.Push(sem_expr->Type()->UnwrapRef());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,6 +135,14 @@ TEST_F(ResolverTest, Stmt_Case) {
|
|||
EXPECT_EQ(sem->Cases()[1]->Selectors().size(), 1u);
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, Stmt_Case_AddressOf_Invalid) {
|
||||
auto* cond_var = Var("i", ty.i32());
|
||||
WrapInFunction(cond_var, Switch("i", Case(CaseSelector(AddressOf(1_a)), Block())));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "error: cannot take the address of expression");
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, Stmt_Block) {
|
||||
auto* v = Var("v", ty.f32());
|
||||
auto* lhs = Expr("v");
|
||||
|
|
Loading…
Reference in New Issue