ast::Variable: Fix nullptr access in info_to_str
With type inference, declared_type_ may be null.
Check it is not null before calling type_name().
Change-Id: I3b7630286b75aa9d021d9cf54eecedc3287a62f2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46872
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
diff --git a/src/ast/variable.cc b/src/ast/variable.cc
index 793cb97..3c7d5a0 100644
--- a/src/ast/variable.cc
+++ b/src/ast/variable.cc
@@ -125,7 +125,9 @@
out << (var_sem ? var_sem->StorageClass() : declared_storage_class())
<< std::endl;
make_indent(out, indent);
- out << declared_type_->type_name() << std::endl;
+ if (declared_type_) {
+ out << declared_type_->type_name() << std::endl;
+ }
}
void Variable::constructor_to_str(const semantic::Info& sem,