ast: Fix nullptr deref in Variable::info_to_str

Varaibles can infer types now, in which case the type_ field is null.

Fixed: chromium:1221120
Change-Id: I0cb2a6a2e8128c56625f48940cf73cf4cadb22ce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55252
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2021-06-21 19:20:16 +00:00 committed by Tint LUCI CQ
parent def7313523
commit 4d94eee072
6 changed files with 36 additions and 1 deletions

View File

@ -85,7 +85,10 @@ void Variable::info_to_str(const sem::Info& sem,
make_indent(out, indent); make_indent(out, indent);
out << declared_access_ << std::endl; out << declared_access_ << std::endl;
make_indent(out, indent); make_indent(out, indent);
out << type_->type_name() << std::endl; if (type_) {
out << type_->type_name();
}
out << std::endl;
} }
void Variable::constructor_to_str(const sem::Info& sem, void Variable::constructor_to_str(const sem::Info& sem,

View File

@ -0,0 +1,2 @@
let
H=1;

View File

@ -0,0 +1,6 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static const int H = 1;

View File

@ -0,0 +1,4 @@
#include <metal_stdlib>
using namespace metal;
constant int H = 1;

View File

@ -0,0 +1,19 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 7
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %H "H"
OpName %unused_entry_point "unused_entry_point"
%int = OpTypeInt 32 1
%H = OpConstant %int 1
%void = OpTypeVoid
%3 = OpTypeFunction %void
%unused_entry_point = OpFunction %void None %3
%6 = OpLabel
OpReturn
OpFunctionEnd

View File

@ -0,0 +1 @@
let H = 1;