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>
This commit is contained in:
Ben Clayton 2021-04-07 15:32:31 +00:00 committed by Commit Bot service account
parent dac5418819
commit 8bd7cc7e88
1 changed files with 3 additions and 1 deletions

View File

@ -125,7 +125,9 @@ void Variable::info_to_str(const semantic::Info& sem,
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,