From 93c563e0735d1354e1802dc6784781011a3daa79 Mon Sep 17 00:00:00 2001 From: Aaron Gutierrez Date: Tue, 2 May 2017 22:26:21 -0400 Subject: [PATCH] Add missing NULL check in CanBeType --- tests_ispcpp/error_0.ispc | 2 +- tests_ispcpp/error_2.ispc | 4 ++-- type.cpp | 20 +++++++++++--------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tests_ispcpp/error_0.ispc b/tests_ispcpp/error_0.ispc index 39f57d0d..46768163 100644 --- a/tests_ispcpp/error_0.ispc +++ b/tests_ispcpp/error_0.ispc @@ -1,6 +1,6 @@ //@error //assigning mismatched polymorphic types -export void foo(floating$0 bar) { +export void foo(uniform floating$0 bar) { floating$1 baz = bar; } diff --git a/tests_ispcpp/error_2.ispc b/tests_ispcpp/error_2.ispc index 6f4adfe0..1be1c6ac 100644 --- a/tests_ispcpp/error_2.ispc +++ b/tests_ispcpp/error_2.ispc @@ -1,6 +1,6 @@ //@error //assigning mismatched polymorphic types -export void foo(number$0 bar) { - floating$0 baz = bar; +export void foo(uniform floating$0 bar) { + integer baz = bar; } diff --git a/type.cpp b/type.cpp index 8450ee23..9da21a0e 100644 --- a/type.cpp +++ b/type.cpp @@ -855,15 +855,17 @@ PolyType::CanBeType(const Type *t) const { const AtomicType *at = CastType(t); - switch (restriction) { - case TYPE_INTEGER: - return at->IsIntType(); - case TYPE_FLOATING: - return at->IsFloatType(); - case TYPE_NUMBER: - return at->IsIntType() || at->IsFloatType(); - default: - FATAL("Unmatched case for polymorphic restriction"); + if (at) { + switch (restriction) { + case TYPE_INTEGER: + return at->IsIntType(); + case TYPE_FLOATING: + return at->IsFloatType(); + case TYPE_NUMBER: + return at->IsIntType() || at->IsFloatType(); + default: + FATAL("Unmatched case for polymorphic restriction"); + } } // not an atomic type or polymorphic type