Fixed a character pointer bug
[fw/sdcc] / src / SDCCast.c
index 772fadb78a5c385f9b3f8ef550db92f29b0abcd9..0519df698c11019670dec4aa08488e7885a877c2 100644 (file)
@@ -414,6 +414,9 @@ int setAstLineno ( ast *tree, int lineno)
     return 0;
 }
 
+#if 0
+/* this functions seems to be superfluous?! kmh */
+
 /*-----------------------------------------------------------------*/
 /* resolveFromTable - will return the symbal table value           */
 /*-----------------------------------------------------------------*/
@@ -439,6 +442,7 @@ value *resolveFromTable (value *val)
 
     return val;
 }
+#endif
 
 /*-----------------------------------------------------------------*/
 /* funcOfType :- function of type with name                        */
@@ -577,10 +581,12 @@ int processParms (ast *func, value *defParm,
        actParm->ftype= defParm->type;
     }
     
-    actParm->argSym = resolveFromTable(defParm)->sym ;
+/*    actParm->argSym = resolveFromTable(defParm)->sym ; */
+    actParm->argSym = defParm->sym;
     /* make a copy and change the regparm type to the defined parm */
     actParm->etype = getSpec(actParm->ftype = copyLinkChain(actParm->ftype));
     SPEC_REGPARM(actParm->etype) = SPEC_REGPARM(defParm->etype);
+    (*parmNumber)++;
     return 0;
 }
 /*-----------------------------------------------------------------*/
@@ -595,7 +601,7 @@ ast *createIvalType ( ast *sym,link  *type, initList *ilist)
        ilist =  ilist->init.deep  ;
     
     iExpr = decorateType(resolveSymbols(list2expr(ilist)));
-    return newNode('=',sym,iExpr);
+    return decorateType(newNode('=',sym,iExpr));
 }
 
 /*-----------------------------------------------------------------*/
@@ -622,8 +628,8 @@ ast *createIvalStruct (ast *sym,link *type,initList *ilist)
        if (!iloop)
            break;
        sflds->implicit = 1;
-       lAst = decorateType(resolveSymbols(newNode('.',sym,
-                                                  newAst(EX_VALUE,symbolVal(sflds)))));
+       lAst = newNode(PTR_OP,newNode('&',sym,NULL),newAst(EX_VALUE,symbolVal(sflds)));
+       lAst = decorateType(resolveSymbols(lAst));
        rast = createIval (lAst, sflds->type, iloop,rast);
     }
     return rast ;
@@ -788,7 +794,7 @@ ast  *createIval  (ast *sym, link *type, initList *ilist, ast *wid)
 }
 
 /*-----------------------------------------------------------------*/
-/* initAggregates - initialises aggregate variables with initv */
+/* initAggregates - initialises aggregate variables with initv     */
 /*-----------------------------------------------------------------*/
 ast *initAggregates ( symbol *sym, initList *ival, ast *wid)
 {
@@ -1226,7 +1232,12 @@ bool isConformingBody (ast *pbody, symbol *sym, ast *body)
                return FALSE;
            else
                return isConformingBody(pbody->left,sym,body) ;
-       } 
+       } else {
+           if (astHasSymbol(pbody->left,sym) ||
+               astHasSymbol(pbody->right,sym))
+               return FALSE;
+       }
+
        
        /*------------------------------------------------------------------*/
     case  '|':
@@ -1517,7 +1528,7 @@ ast *decorateType (ast *tree)
                  TTYPE(tree) = TETYPE(tree) =
                    tree->opval.val->type = tree->opval.val->sym->type = 
                    tree->opval.val->etype = tree->opval.val->sym->etype = 
-                   copyLinkChain(intType);
+                   copyLinkChain(INTTYPE);
                }
                else {
                  
@@ -1751,7 +1762,7 @@ ast *decorateType (ast *tree)
        }
        if (SPEC_SCLS(tree->left->etype) == S_CODE) {
            DCL_TYPE(p) = CPOINTER ;
-           DCL_PTR_CONST(p) = 1;
+           DCL_PTR_CONST(p) = port->mem.code_ro;
        }
        else
            if (SPEC_SCLS(tree->left->etype) == S_XDATA)
@@ -1763,8 +1774,8 @@ ast *decorateType (ast *tree)
                    if (SPEC_SCLS(tree->left->etype) == S_IDATA)
                        DCL_TYPE(p) = IPOINTER ;
                    else
-                       if (SPEC_SCLS(tree->left->etype) == S_FLASH)
-                           DCL_TYPE(p) = FLPOINTER ;
+                       if (SPEC_SCLS(tree->left->etype) == S_EEPROM)
+                           DCL_TYPE(p) = EEPPOINTER ;
                        else
                            DCL_TYPE(p) = POINTER ;
 
@@ -2213,7 +2224,11 @@ ast *decorateType (ast *tree)
            return tree;
        }
        LRVAL(tree) = RRVAL(tree) = 1;
-       COPYTYPE(TTYPE(tree),TETYPE(tree),LTYPE(tree));
+       if (IS_LITERAL(LTYPE(tree)) && !IS_LITERAL(RTYPE(tree))) {          
+           COPYTYPE(TTYPE(tree),TETYPE(tree),RTYPE(tree));     
+       } else {
+           COPYTYPE(TTYPE(tree),TETYPE(tree),LTYPE(tree));
+       }
        return tree ;
         
        /*------------------------------------------------------------------*/