compiler/libec: Fixed warning in call to Unserialize for struct parameter
authorJerome St-Louis <jerome@ecere.com>
Wed, 2 Jul 2014 14:52:12 +0000 (10:52 -0400)
committerJerome St-Louis <jerome@ecere.com>
Wed, 2 Jul 2014 14:52:12 +0000 (10:52 -0400)
- Found in distributed objects code in crossWords.main.ec

compiler/bootstrap/libec/bootstrap/pass3.c
compiler/libec/src/pass3.ec

index 8dabc83..e4190c0 100644 (file)
@@ -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;
index f578601..8fe0348 100644 (file)
@@ -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;