From 5752156bc7089f37f974b945f81c711fb03c8f0f Mon Sep 17 00:00:00 2001 From: Jerome St-Louis Date: Wed, 2 Jul 2014 10:52:12 -0400 Subject: [PATCH] compiler/libec: Fixed warning in call to Unserialize for struct parameter - Found in distributed objects code in crossWords.main.ec --- compiler/bootstrap/libec/bootstrap/pass3.c | 8 +++++++- compiler/libec/src/pass3.ec | 11 +++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/compiler/bootstrap/libec/bootstrap/pass3.c b/compiler/bootstrap/libec/bootstrap/pass3.c index 8dabc83..e4190c0 100644 --- a/compiler/bootstrap/libec/bootstrap/pass3.c +++ b/compiler/bootstrap/libec/bootstrap/pass3.c @@ -2205,9 +2205,15 @@ if(exp->__anon1.call.arguments) { for(e = (*exp->__anon1.call.arguments).first; e; e = e->next) { +unsigned int addCast = 0; + InstDeclPassExpression(e); AddPointerCast(e); -if(e->expType && e->expType->kind == 13 && e->expType->__anon1.type && (e->expType->__anon1.type->kind == 8 || (e->expType->__anon1.type->kind == 13 && e->expType->__anon1.type->__anon1.type && e->expType->__anon1.type->__anon1.type->kind != 0)) && e->destType && e->destType->kind == 13 && e->destType->__anon1.type && e->destType->__anon1.type->kind == 13 && e->destType->__anon1.type->__anon1.type && e->destType->__anon1.type->__anon1.type->kind == 0 && (e->type != 11 || !IsVoidPtrCast(e->__anon1.cast.typeName))) +if(e->expType && e->expType->kind == 13 && e->expType->__anon1.type && (e->expType->__anon1.type->kind == 8 || (e->expType->__anon1.type->kind == 13 && e->expType->__anon1.type->__anon1.type && e->expType->__anon1.type->__anon1.type->kind != 0)) && e->destType && e->destType->kind == 13 && e->destType->__anon1.type && e->destType->__anon1.type->kind == 13 && e->destType->__anon1.type->__anon1.type && e->destType->__anon1.type->__anon1.type->kind == 0) +addCast = 1; +else if(e->expType && e->expType->kind == 8 && e->expType->__anon1._class && e->expType->__anon1._class->__anon1.registered && e->expType->__anon1._class->__anon1.registered->type == 1 && e->byReference && e->destType && e->destType->kind == 8 && e->destType->classObjectType && e->destType->byReference) +addCast = 1; +if(addCast && (e->type != 11 || !IsVoidPtrCast(e->__anon1.cast.typeName))) { e->__anon1.cast.exp = MkExpBrackets(MkListOne(MoveExpContents(e))); e->type = 11; diff --git a/compiler/libec/src/pass3.ec b/compiler/libec/src/pass3.ec index f578601..8fe0348 100644 --- a/compiler/libec/src/pass3.ec +++ b/compiler/libec/src/pass3.ec @@ -575,12 +575,19 @@ static void InstDeclPassExpression(Expression exp) { for(e = exp.call.arguments->first; e; e = e.next) { + bool addCast = false; InstDeclPassExpression(e); AddPointerCast(e); if(e.expType && e.expType.kind == pointerType && e.expType.type && (e.expType.type.kind == classType || (e.expType.type.kind == pointerType && e.expType.type.type && e.expType.type.type.kind != voidType)) && - e.destType && e.destType.kind == pointerType && e.destType.type && e.destType.type.kind == pointerType && e.destType.type.type && e.destType.type.type.kind == voidType && - (e.type != castExp || !IsVoidPtrCast(e.cast.typeName))) + e.destType && e.destType.kind == pointerType && e.destType.type && e.destType.type.kind == pointerType && e.destType.type.type && e.destType.type.type.kind == voidType) + addCast = true; + // Fix for adding a cast to Unserialize with a struct passed as a parameter: + else if(e.expType && e.expType.kind == classType && e.expType._class && e.expType._class.registered && e.expType._class.registered.type == structClass && e.byReference && + e.destType && e.destType.kind == classType && e.destType.classObjectType && e.destType.byReference) + addCast = true; + + if(addCast && (e.type != castExp || !IsVoidPtrCast(e.cast.typeName))) { e.cast.exp = MkExpBrackets(MkListOne(MoveExpContents(e))); e.type = castExp; -- 1.8.3.1