resolver: Fix ICE when using a builtin as a type
Bug: chromium:1308209 Change-Id: I779d7fcb4a32640663077cb2176875f6081098a0 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/84260 Reviewed-by: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
7d38b88d77
commit
e07c40af14
|
@ -275,6 +275,14 @@ sem::Type* Resolver::Type(const ast::Type* ty) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
},
|
},
|
||||||
[&](Default) {
|
[&](Default) {
|
||||||
|
if (auto* tn = ty->As<ast::TypeName>()) {
|
||||||
|
if (IsBuiltin(tn->name)) {
|
||||||
|
auto name = builder_->Symbols().NameFor(tn->name);
|
||||||
|
AddError("cannot use builtin '" + name + "' as type",
|
||||||
|
ty->source);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
TINT_UNREACHABLE(Resolver, diagnostics_)
|
TINT_UNREACHABLE(Resolver, diagnostics_)
|
||||||
<< "Unhandled resolved type '"
|
<< "Unhandled resolved type '"
|
||||||
<< (resolved ? resolved->TypeInfo().name : "<null>")
|
<< (resolved ? resolved->TypeInfo().name : "<null>")
|
||||||
|
|
|
@ -705,6 +705,14 @@ TEST_F(ResolverTypeValidationTest, FunctionAsType) {
|
||||||
note: 'f' declared here)");
|
note: 'f' declared here)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ResolverTypeValidationTest, BuiltinAsType) {
|
||||||
|
// var<private> v : max;
|
||||||
|
Global("v", ty.type_name("max"), ast::StorageClass::kPrivate);
|
||||||
|
|
||||||
|
EXPECT_FALSE(r()->Resolve());
|
||||||
|
EXPECT_EQ(r()->error(), "error: cannot use builtin 'max' as type");
|
||||||
|
}
|
||||||
|
|
||||||
namespace GetCanonicalTests {
|
namespace GetCanonicalTests {
|
||||||
struct Params {
|
struct Params {
|
||||||
builder::ast_type_func_ptr create_ast_type;
|
builder::ast_type_func_ptr create_ast_type;
|
||||||
|
|
Loading…
Reference in New Issue