Use foo->source() instead of foo->type()->source() in errors
In these circumstances foo->type() may be null. BUG=chromium:1238462 Change-Id: I77ed142e3f61f6af52a07e59e290f65613af3514 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61660 Auto-Submit: Ryan Harrison <rharrison@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: David Neto <dneto@google.com> Reviewed-by: David Neto <dneto@google.com> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
parent
36747d7046
commit
3bcbfc7862
|
@ -411,7 +411,8 @@ bool Resolver::ValidateAtomic(const ast::Atomic* a, const sem::Atomic* s) {
|
||||||
// https://gpuweb.github.io/gpuweb/wgsl/#atomic-types
|
// https://gpuweb.github.io/gpuweb/wgsl/#atomic-types
|
||||||
// T must be either u32 or i32.
|
// T must be either u32 or i32.
|
||||||
if (!s->Type()->IsAnyOf<sem::U32, sem::I32>()) {
|
if (!s->Type()->IsAnyOf<sem::U32, sem::I32>()) {
|
||||||
AddError("atomic only supports i32 or u32 types", a->type()->source());
|
AddError("atomic only supports i32 or u32 types",
|
||||||
|
a->type() ? a->type()->source() : a->source());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1043,13 +1044,14 @@ bool Resolver::ValidateAtomicVariable(const VariableInfo* info) {
|
||||||
auto sc = info->storage_class;
|
auto sc = info->storage_class;
|
||||||
auto access = info->access;
|
auto access = info->access;
|
||||||
auto* type = info->type->UnwrapRef();
|
auto* type = info->type->UnwrapRef();
|
||||||
auto source = info->declaration->type()->source();
|
auto source = info->declaration->type() ? info->declaration->type()->source()
|
||||||
|
: info->declaration->source();
|
||||||
|
|
||||||
if (type->Is<sem::Atomic>()) {
|
if (type->Is<sem::Atomic>()) {
|
||||||
if (sc != ast::StorageClass::kWorkgroup) {
|
if (sc != ast::StorageClass::kWorkgroup) {
|
||||||
AddError(
|
AddError(
|
||||||
"atomic variables must have <storage> or <workgroup> storage class",
|
"atomic variables must have <storage> or <workgroup> storage class",
|
||||||
info->declaration->type()->source());
|
source);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (type->IsAnyOf<sem::Struct, sem::Array>()) {
|
} else if (type->IsAnyOf<sem::Struct, sem::Array>()) {
|
||||||
|
@ -3382,7 +3384,7 @@ bool Resolver::VariableDeclStatement(const ast::VariableDeclStatement* stmt) {
|
||||||
ast::DisabledValidation::kIgnoreStorageClass)) {
|
ast::DisabledValidation::kIgnoreStorageClass)) {
|
||||||
if (!info->type->UnwrapRef()->IsConstructible()) {
|
if (!info->type->UnwrapRef()->IsConstructible()) {
|
||||||
AddError("function variable must have a constructible type",
|
AddError("function variable must have a constructible type",
|
||||||
var->type()->source());
|
var->type() ? var->type()->source() : var->source());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (info->storage_class != ast::StorageClass::kFunction) {
|
if (info->storage_class != ast::StorageClass::kFunction) {
|
||||||
|
|
Loading…
Reference in New Issue