From b19a4c613da36911745d1f766bc03c57eaeef30b Mon Sep 17 00:00:00 2001 From: Lucas de Vries Date: Tue, 17 Jul 2018 16:21:11 +0200 Subject: [PATCH] Fixes for newer GCC version. --- source/angelscript/source/as_builder.cpp | 5 ++++- source/angelscript/source/as_compiler.cpp | 8 +++++--- source/angelscript/source/as_scriptengine.cpp | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/source/angelscript/source/as_builder.cpp b/source/angelscript/source/as_builder.cpp index 5c555f0..012735d 100644 --- a/source/angelscript/source/as_builder.cpp +++ b/source/angelscript/source/as_builder.cpp @@ -5673,7 +5673,10 @@ asCTypeInfo *asCBuilder::GetType(const char *type, asSNameSpace *ns, asCObjectTy asCObjectType *asCBuilder::GetObjectType(const char *type, asSNameSpace *ns) { - return GetType(type, ns, 0)->CastToObjectType(); + auto* typeInfo = GetType(type, ns, 0); + if(!typeInfo) + return nullptr; + return typeInfo->CastToObjectType(); } #ifndef AS_NO_COMPILER diff --git a/source/angelscript/source/as_compiler.cpp b/source/angelscript/source/as_compiler.cpp index 9cf6329..db219dc 100644 --- a/source/angelscript/source/as_compiler.cpp +++ b/source/angelscript/source/as_compiler.cpp @@ -6155,7 +6155,8 @@ asUINT asCCompiler::ImplicitConvObjectToPrimitive(asCExprContext *ctx, const asC // Find matching value cast behaviours // Here we're only interested in those that convert the type to a primitive type asCArray funcs; - asCObjectType *ot = ctx->type.dataType.GetTypeInfo()->CastToObjectType(); + auto *typeInfo = ctx->type.dataType.GetTypeInfo(); + asCObjectType *ot = typeInfo ? typeInfo->CastToObjectType() : 0; if( ot == 0 ) { if( convType != asIC_IMPLICIT_CONV && node ) @@ -6467,7 +6468,8 @@ asUINT asCCompiler::ImplicitConvObjectValue(asCExprContext *ctx, const asCDataTy if( to.GetTypeInfo() != ctx->type.dataType.GetTypeInfo() ) { // TODO: Implement support for implicit constructor/factory - asCObjectType *ot = ctx->type.dataType.GetTypeInfo()->CastToObjectType(); + auto* typeInfo =ctx->type.dataType.GetTypeInfo(); + asCObjectType *ot = typeInfo ? typeInfo->CastToObjectType() : 0; if( ot == 0 ) return cost; @@ -8827,7 +8829,7 @@ int asCCompiler::CompileVariableAccess(const asCString &name, const asCString &s if( currScope != "" && currScope != "::" ) { builder->GetNameSpaceByString(currScope, outFunc->objectType ? outFunc->objectType->nameSpace : outFunc->nameSpace, errNode, script, &scopeType, false); - if (scopeType->CastToEnumType() == 0) + if (scopeType && scopeType->CastToEnumType() == 0) scopeType = 0; } diff --git a/source/angelscript/source/as_scriptengine.cpp b/source/angelscript/source/as_scriptengine.cpp index 20af74e..1d65587 100644 --- a/source/angelscript/source/as_scriptengine.cpp +++ b/source/angelscript/source/as_scriptengine.cpp @@ -6269,7 +6269,7 @@ void asCScriptEngine::DestroySubList(asBYTE *&buffer, asSListPatternNode *&node) dt = GetDataTypeFromTypeId(typeId); } - asCObjectType *ot = dt.GetTypeInfo()->CastToObjectType(); + asCObjectType *ot = (asCObjectType*)dt.GetTypeInfo(); if( ot && (ot->flags & asOBJ_ENUM) == 0 ) { // Free all instances of this type