From 621679245a4567a385fdeeed9af944ed45d691c0 Mon Sep 17 00:00:00 2001 From: Ilia Filippov Date: Fri, 25 Oct 2013 12:49:06 +0400 Subject: [PATCH] fixing problem 644 --- expr.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/expr.cpp b/expr.cpp index c92503e0..222c89a1 100644 --- a/expr.cpp +++ b/expr.cpp @@ -7065,9 +7065,22 @@ TypeCastExpr::GetLValue(FunctionEmitContext *ctx) const { const Type * TypeCastExpr::GetType() const { - // We have to switch off this assert after supporting of operators. - //AssertPos(pos, type->HasUnboundVariability() == false); - return type; + // Here we try to resolve situation where (base_type) can be treated as + // (uniform base_type) of (varying base_type). This is a part of function + // TypeCastExpr::TypeCheck. After implementation of operators we + // have to have this functionality here. + const Type *toType = type, *fromType = expr->GetType(); + if (toType == NULL || fromType == NULL) + return NULL; + if (toType->HasUnboundVariability()) { + if (fromType->IsUniformType()) { + toType = type->ResolveUnboundVariability(Variability::Uniform); + } else { + toType = type->ResolveUnboundVariability(Variability::Varying); + } + } + AssertPos(pos, toType->HasUnboundVariability() == false); + return toType; }