Merge of the izt changes.
[fw/sdcc] / src / SDCCast.c
index dc3a36e8790b2e1c4136c3bdc913041c9aac5314..c56f9c822ce329295fef979e8b7284a395e9ba4c 100644 (file)
@@ -27,7 +27,6 @@
 int currLineno  = 0;
 set *astList = NULL ;
 set *operKeyReset = NULL;
-extern char *currFname ;
 ast *staticAutos = NULL;
 int labelKey = 1 ;
 
@@ -50,12 +49,8 @@ char  buffer[1024];
 int noLineno = 0;
 int noAlloc = 0 ;
 symbol *currFunc ;
-extern int fatalError ;
-extern int lineno;
-extern char *filename ;
-extern set *publics;
-extern ast  *createIval  (ast *, link *, initList *, ast *);
-extern ast *createIvalCharPtr (ast *, link *, ast *);
+ast  *createIval  (ast *, sym_link *, initList *, ast *);
+ast *createIvalCharPtr (ast *, sym_link *, ast *);
 ast *optimizeRRCRLC ( ast * );
 ast *optimizeGetHbit(ast *);
 ast *backPatchLabels (ast *,symbol *,symbol *);
@@ -70,6 +65,7 @@ int ptt(ast *tree) {
 /*-----------------------------------------------------------------*/
 /* newAst - creates a fresh node for an expression tree           */
 /*-----------------------------------------------------------------*/
+#if 0
 ast  *newAst (int  type, void *op )
 {
     ast  *ex ;
@@ -90,10 +86,10 @@ ast  *newAst (int  type, void *op )
        ex->opval.val = (value *) op;
        break ;
     case EX_OP     :
-       ex->opval.op   = (int) op ;
+       ex->opval.op   = (long) op ;
        break ;
     case EX_LINK   :
-       ex->opval.lnk  = (link *) op;
+       ex->opval.lnk  = (sym_link *) op;
        break ;
     case EX_STMNT  :
        ex->opval.stmnt= (unsigned) op;
@@ -101,15 +97,60 @@ ast  *newAst (int  type, void *op )
     
     return ex;
 }
+#endif
+
+static ast* newAst_(unsigned type)
+{
+    ast  *ex ;
+    static int oldLineno = 0 ;
+
+    ALLOC(ex,sizeof(ast));    
+    
+    ex->type = type ;          
+    ex->lineno = (noLineno ? oldLineno : yylineno);
+    ex->filename = currFname ;
+    ex->level = NestLevel ;
+    ex->block = currBlockno ;
+    ex->initMode = inInitMode;
+    return ex;
+}
+
+ast* newAst_VALUE(value*val)
+{
+      ast* ex = newAst_(EX_VALUE);
+      ex->opval.val = val;
+      return ex;
+}
+
+ast* newAst_OP(unsigned op)
+{
+      ast*ex = newAst_(EX_OP);
+      ex->opval.op = op;
+      return ex;
+}
+
+ast* newAst_LINK(sym_link*val)
+{
+      ast* ex = newAst_(EX_LINK);
+      ex->opval.lnk = val;
+      return ex;
+}
+
+ast* newAst_STMNT(unsigned val)
+{
+      ast* ex = newAst_(EX_STMNT);
+      ex->opval.stmnt = val;
+      return ex;
+}
 
 /*-----------------------------------------------------------------*/
 /* newNode - creates a new node                                    */
 /*-----------------------------------------------------------------*/
-ast  *newNode ( int op,   ast  *left, ast *right   )
+ast  *newNode ( long op,   ast  *left, ast *right   )
 {
     ast  *ex ;
     
-    ex = newAst (EX_OP,(void *) op) ;
+    ex = newAst_OP(op) ;
     ex->left    = left ;
     ex->right   = right;
         
@@ -128,11 +169,13 @@ ast *newIfxNode (ast *condAst, symbol *trueLabel, symbol *falseLabel)
        
        /* then depending on the expression value */
        if ( floatFromVal(condAst->opval.val) )
-           ifxNode = newNode(GOTO, newAst(EX_VALUE,
-                                          symbolVal (trueLabel )),NULL);
+             ifxNode = newNode(GOTO,
+                               newAst_VALUE(symbolVal(trueLabel)),
+                               NULL);
        else
-           ifxNode = newNode(GOTO, newAst(EX_VALUE,
-                                          symbolVal (falseLabel )),NULL);
+             ifxNode = newNode(GOTO,
+                               newAst_VALUE(symbolVal(falseLabel)),
+                               NULL);
     }
     else {
        ifxNode = newNode(IFX,condAst,NULL);
@@ -447,7 +490,7 @@ value *resolveFromTable (value *val)
 /*-----------------------------------------------------------------*/
 /* funcOfType :- function of type with name                        */
 /*-----------------------------------------------------------------*/
-symbol *funcOfType (char *name, link *type, link *argType, 
+symbol *funcOfType (char *name, sym_link *type, sym_link *argType, 
                    int nArgs , int rent)
 {
     symbol *sym;    
@@ -516,7 +559,7 @@ int processParms (ast *func, value *defParm,
                  ast *actParm, 
                  int *parmNumber)
 {
-    link *fetype = func->etype;
+    sym_link *fetype = func->etype;
     
     /* if none of them exist */
     if ( !defParm && !actParm)
@@ -545,10 +588,50 @@ int processParms (ast *func, value *defParm,
        return 1;
     }
         
+    /* If this is a varagrs function... */ 
+    if (!defParm && actParm && func->hasVargs )
+    {
+        ast *newType = NULL;
+        
+       if (IS_CAST_OP(actParm) 
+        || (IS_AST_LIT_VALUE(actParm) && actParm->values.literalFromCast))
+       {
+          /* Parameter was explicitly typecast; don't touch it. */
+          return 0;
+       }    
+        
+        /* If it's a small integer, upcast to int. */
+       if (IS_INTEGRAL(actParm->ftype)
+         && getSize(actParm->ftype) < INTSIZE)
+        {
+           newType = newAst_LINK(INTTYPE);
+        }
+        
+        if (IS_PTR(actParm->ftype) && !IS_GENPTR(actParm->ftype))
+        {
+            newType = newAst_LINK(copyLinkChain(actParm->ftype));
+            DCL_TYPE(newType->opval.lnk) = GPOINTER;
+        }
+        
+        if (newType)
+        {
+           /* cast required; change this op to a cast. */
+            ast *parmCopy = resolveSymbols(copyAst(actParm));
+           
+           actParm->type = EX_OP;
+           actParm->opval.op = CAST;
+           actParm->left = newType;
+           actParm->right= parmCopy;
+           decorateType(actParm);           
+        }
+        
+        return 0;
+    }        
+        
     /* if defined parameters ended but actual has not & */
-    /* has a variable argument list or statckAuto       */
+    /* stackAuto                                               */
     if (! defParm && actParm && 
-       (func->hasVargs || options.stackAuto || IS_RENT(fetype)))
+       (options.stackAuto || IS_RENT(fetype)))
        return 0;
     
     resolveSymbols(actParm);
@@ -575,7 +658,7 @@ int processParms (ast *func, value *defParm,
        /* now change the current one to a cast */      
        actParm->type = EX_OP ;
        actParm->opval.op = CAST ;
-       actParm->left = newAst(EX_LINK,defParm->type);
+       actParm->left = newAst_LINK(defParm->type);
        actParm->right= pTree ;
        actParm->etype= defParm->etype;
        actParm->ftype= defParm->type;
@@ -592,7 +675,7 @@ int processParms (ast *func, value *defParm,
 /*-----------------------------------------------------------------*/
 /* createIvalType - generates ival for basic types                 */
 /*-----------------------------------------------------------------*/
-ast *createIvalType ( ast *sym,link  *type, initList *ilist)
+ast *createIvalType ( ast *sym,sym_link  *type, initList *ilist)
 {
     ast *iExpr;
 
@@ -607,7 +690,7 @@ ast *createIvalType ( ast *sym,link  *type, initList *ilist)
 /*-----------------------------------------------------------------*/
 /* createIvalStruct - generates initial value for structures       */
 /*-----------------------------------------------------------------*/
-ast *createIvalStruct (ast *sym,link *type,initList *ilist)
+ast *createIvalStruct (ast *sym,sym_link *type,initList *ilist)
 {
     ast *rast = NULL ;
     symbol   *sflds  ;
@@ -628,7 +711,7 @@ ast *createIvalStruct (ast *sym,link *type,initList *ilist)
        if (!iloop)
            break;
        sflds->implicit = 1;
-       lAst = newNode(PTR_OP,newNode('&',sym,NULL),newAst(EX_VALUE,symbolVal(sflds)));
+       lAst = newNode(PTR_OP,newNode('&',sym,NULL),newAst_VALUE(symbolVal(sflds)));
        lAst = decorateType(resolveSymbols(lAst));
        rast = decorateType(resolveSymbols(createIval (lAst, sflds->type, iloop,rast)));
     }
@@ -639,7 +722,7 @@ ast *createIvalStruct (ast *sym,link *type,initList *ilist)
 /*-----------------------------------------------------------------*/
 /* createIvalArray - generates code for array initialization       */
 /*-----------------------------------------------------------------*/
-ast *createIvalArray (ast  *sym, link *type, initList *ilist)
+ast *createIvalArray (ast  *sym, sym_link *type, initList *ilist)
 {
     ast *rast = NULL;
     initList *iloop ;
@@ -668,7 +751,7 @@ ast *createIvalArray (ast  *sym, link *type, initList *ilist)
        ast *aSym ;
        size++ ;
 
-       aSym = newNode('[',sym,newAst(EX_VALUE,valueFromLit(size-1)));
+       aSym = newNode('[',sym,newAst_VALUE(valueFromLit(size-1)));
        aSym = decorateType(resolveSymbols(aSym));
        rast = createIval (aSym,type->next,iloop,rast)   ;
        iloop = (iloop ? iloop->next : NULL) ;
@@ -696,7 +779,7 @@ ast *createIvalArray (ast  *sym, link *type, initList *ilist)
 /*-----------------------------------------------------------------*/
 /* createIvalCharPtr - generates initial values for char pointers  */
 /*-----------------------------------------------------------------*/
-ast *createIvalCharPtr (ast *sym, link *type, ast *iexpr)
+ast *createIvalCharPtr (ast *sym, sym_link *type, ast *iexpr)
 {      
     ast *rast = NULL ;
 
@@ -723,8 +806,8 @@ ast *createIvalCharPtr (ast *sym, link *type, ast *iexpr)
                           rast,
                           newNode('=',
                                   newNode('[', sym,
-                                          newAst(EX_VALUE,valueFromLit(i))),
-                                  newAst(EX_VALUE,valueFromLit(*s))));
+                                          newAst_VALUE(valueFromLit(i))),
+                                  newAst_VALUE(valueFromLit(*s))));
            i++;
            s++;
        }
@@ -732,8 +815,8 @@ ast *createIvalCharPtr (ast *sym, link *type, ast *iexpr)
                           rast,
                           newNode('=',
                                   newNode('[', sym,
-                                          newAst(EX_VALUE,valueFromLit(i))),
-                                  newAst(EX_VALUE,valueFromLit(*s))));
+                                          newAst_VALUE(valueFromLit(i))),
+                                  newAst_VALUE(valueFromLit(*s))));
        return decorateType(resolveSymbols(rast));
     }
 
@@ -743,7 +826,7 @@ ast *createIvalCharPtr (ast *sym, link *type, ast *iexpr)
 /*-----------------------------------------------------------------*/
 /* createIvalPtr - generates initial value for pointers            */
 /*-----------------------------------------------------------------*/
-ast *createIvalPtr (ast *sym,link *type,initList *ilist)
+ast *createIvalPtr (ast *sym,sym_link *type,initList *ilist)
 {    
     ast *rast;
     ast *iexpr ;
@@ -765,7 +848,7 @@ ast *createIvalPtr (ast *sym,link *type,initList *ilist)
 /*-----------------------------------------------------------------*/
 /* createIval - generates code for initial value                   */
 /*-----------------------------------------------------------------*/
-ast  *createIval  (ast *sym, link *type, initList *ilist, ast *wid)
+ast  *createIval  (ast *sym, sym_link *type, initList *ilist, ast *wid)
 {
     ast *rast = NULL;  
 
@@ -798,7 +881,7 @@ ast  *createIval  (ast *sym, link *type, initList *ilist, ast *wid)
 /*-----------------------------------------------------------------*/
 ast *initAggregates ( symbol *sym, initList *ival, ast *wid)
 {
-    return createIval (newAst(EX_VALUE,symbolVal(sym)),sym->type,ival,wid);
+    return createIval (newAst_VALUE(symbolVal(sym)),sym->type,ival,wid);
 }
 
 /*-----------------------------------------------------------------*/
@@ -835,7 +918,7 @@ ast *gatherAutoInit ( symbol *autoChain )
            if (IS_AGGREGATE(sym->type))
                work = initAggregates (sym, sym->ival,NULL);
            else
-               work = newNode('=' ,newAst(EX_VALUE,symbolVal(newSym)),
+               work = newNode('=' ,newAst_VALUE(symbolVal(newSym)),
                               list2expr(sym->ival));
            
            setAstLineno(work,sym->lineDef);
@@ -854,7 +937,7 @@ ast *gatherAutoInit ( symbol *autoChain )
            if (IS_AGGREGATE(sym->type)) 
                work = initAggregates (sym,sym->ival,NULL);
            else
-               work = newNode('=' ,newAst(EX_VALUE,symbolVal(sym)),
+               work = newNode('=' ,newAst_VALUE(symbolVal(sym)),
                               list2expr(sym->ival));
            
            setAstLineno (work,sym->lineDef);
@@ -893,7 +976,7 @@ static value *stringToSymbol (value *val)
     sym->block = sym->level = 0;
     sym->isstrlit = 1;
     /* create an ival */
-    sym->ival = newiList(INIT_NODE,newAst(EX_VALUE,val));
+    sym->ival = newiList(INIT_NODE,newAst_VALUE(val));
     if (noAlloc == 0) {
        /* allocate it */
        addSymChain(sym);
@@ -1049,7 +1132,7 @@ bool isLoopCountable (ast *initExpr, ast *condExpr, ast *loopExpr,
                isSymbolEqual (*sym,AST_SYMBOL(condExpr->left->left))) {
                
                *end = newNode('+', condExpr->left->right,
-                              newAst(EX_VALUE,constVal("1")));
+                              newAst_VALUE(constVal("1")));
                break;
            }
            return FALSE ;
@@ -1405,8 +1488,8 @@ static void replLoopSym ( ast *body, symbol *sym)
            
            body->type = EX_OP;
            body->opval.op = '-';
-           body->left = newAst(EX_VALUE,symbolVal(sym));
-           body->right= newAst(EX_VALUE,constVal("1"));
+           body->left = newAst_VALUE(symbolVal(sym));
+           body->right= newAst_VALUE(constVal("1"));
 
        }
            
@@ -1432,40 +1515,102 @@ ast *reverseLoop (ast *loop, symbol *sym, ast *init, ast *end)
                forbody
                <sym> -= 1;
                if (sym) goto for_continue ; 
-               <sym> = end - 1; */
+               <sym> = end */
     
     /* put it together piece by piece */
     rloop = newNode (NULLOP,
-                    createIf(newAst(EX_VALUE,symbolVal(sym)),
+                    createIf(newAst_VALUE(symbolVal(sym)),
                              newNode(GOTO,
-                                     newAst(EX_VALUE,
-                                            symbolVal(AST_FOR(loop,continueLabel))),
+                                     newAst_VALUE(symbolVal(AST_FOR(loop,continueLabel))),
                                      NULL),NULL),
                     newNode('=',
-                            newAst(EX_VALUE,symbolVal(sym)),
-                            newNode('-', end,
-                                    newAst(EX_VALUE,
-                                           constVal("1")))));
+                            newAst_VALUE(symbolVal(sym)),
+                            end));
 
     replLoopSym(loop->left, sym);
 
     rloop = newNode(NULLOP,
                    newNode('=',
-                           newAst(EX_VALUE,symbolVal(sym)),
+                           newAst_VALUE(symbolVal(sym)),
                            newNode('-',end,init)),
                    createLabel(AST_FOR(loop,continueLabel),
                                newNode(NULLOP,
                                        loop->left,
                                        newNode(NULLOP,
                                                newNode(SUB_ASSIGN,
-                                                       newAst(EX_VALUE,symbolVal(sym)),
-                                                       newAst(EX_VALUE,constVal("1"))),
+                                                       newAst_VALUE(symbolVal(sym)),
+                                                       newAst_VALUE(constVal("1"))),
                                                rloop ))));
     
     return decorateType(rloop);
 
 }
 
+#define DEMAND_INTEGER_PROMOTION
+
+#ifdef DEMAND_INTEGER_PROMOTION
+
+/*-----------------------------------------------------------------*/
+/* walk a tree looking for the leaves. Add a typecast to the given */
+/* type to each value leaf node.                                  */
+/*-----------------------------------------------------------------*/
+void pushTypeCastToLeaves(sym_link *type, ast *node, ast **parentPtr)
+{
+    if (!node)
+    {
+        /* WTF? We should never get here. */
+        return;
+    }
+    
+    if (!node->left && !node->right)
+    {
+        /* We're at a leaf; if it's a value, apply the typecast */
+        if (node->type == EX_VALUE && IS_INTEGRAL(TTYPE(node)))
+        {
+            *parentPtr = decorateType(newNode(CAST,
+                                             newAst_LINK(copyLinkChain(type)),
+                                             node));
+       }
+    }
+    else
+    {
+       if (node->left)
+       {
+           pushTypeCastToLeaves(type, node->left, &(node->left));
+       }
+       if (node->right)
+       {
+            pushTypeCastToLeaves(type, node->right, &(node->right));
+       }
+    }
+}
+
+#endif
+
+/*-----------------------------------------------------------------*/
+/* Given an assignment operation in a tree, determine if the LHS   */
+/* (the result) has a different (integer) type than the RHS.      */
+/* If so, walk the RHS and add a typecast to the type of the LHS   */
+/* to all leaf nodes.                                             */
+/*-----------------------------------------------------------------*/
+void propAsgType(ast *tree)
+{
+#ifdef DEMAND_INTEGER_PROMOTION
+    if (!IS_INTEGRAL(LTYPE(tree)) || !IS_INTEGRAL(RTYPE(tree)))
+    {
+       /* Nothing to do here... */
+       return;
+    }
+    
+    if (getSize(LTYPE(tree)) > getSize(RTYPE(tree)))
+    {
+        pushTypeCastToLeaves(LTYPE(tree), tree->right, &(tree->right));
+    }
+#else
+    (void)tree;
+#endif        
+}
+
 /*-----------------------------------------------------------------*/
 /* decorateType - compute type for this tree also does type cheking*/
 /*          this is done bottom up, since type have to flow upwards*/
@@ -1474,7 +1619,7 @@ ast *reverseLoop (ast *loop, symbol *sym, ast *init, ast *end)
 ast *decorateType (ast *tree)
 {         
     int parmNumber ;
-    link *p;
+    sym_link *p;
     
     if ( ! tree )
        return tree ;
@@ -1517,6 +1662,10 @@ ast *decorateType (ast *tree)
            
            /* otherwise just copy the type information */
            COPYTYPE(TTYPE(tree),TETYPE(tree),tree->opval.val->type);
+           if (funcInChain(tree->opval.val->type)) {
+                   tree->hasVargs = tree->opval.val->sym->hasVargs;
+                   tree->args = copyValueChain(tree->opval.val->sym->args) ;
+           }
            return tree ;
        }
        
@@ -1659,7 +1808,7 @@ ast *decorateType (ast *tree)
     case  INC_OP:  /* incerement operator unary so left only */
     case  DEC_OP:
        {
-           link *ltc = (tree->right ? RTYPE(tree) : LTYPE(tree) );
+           sym_link *ltc = (tree->right ? RTYPE(tree) : LTYPE(tree) );
            COPYTYPE(TTYPE(tree),TETYPE(tree),ltc);
            if (!tree->initMode && IS_CONSTANT(TETYPE(tree)))
                werror(E_CODE_WRITE,"++/--");
@@ -2235,7 +2384,7 @@ ast *decorateType (ast *tree)
        /*----------------------------*/
        /*         casting            */
        /*----------------------------*/
-    case CAST   :  /* change the type   */
+    case CAST:  /* change the type   */
        /* cannot cast to an aggregate type */
        if (IS_AGGREGATE(LTYPE(tree))) {
            werror(E_CAST_ILLEGAL);
@@ -2251,6 +2400,7 @@ ast *decorateType (ast *tree)
            tree->left = NULL;
            tree->right = NULL;
            TTYPE(tree) = tree->opval.val->type;            
+           tree->values.literalFromCast = 1;
        }
        else {
            TTYPE(tree) = LTYPE(tree);
@@ -2266,7 +2416,7 @@ ast *decorateType (ast *tree)
        /*       logical &&, ||       */
        /*----------------------------*/
     case AND_OP:
-    case OR_OP :
+    case OR_OP:
        /* each must me arithmetic type or be a pointer */
        if (!IS_PTR(LTYPE(tree)) && 
            !IS_ARRAY(LTYPE(tree)) && 
@@ -2419,6 +2569,9 @@ ast *decorateType (ast *tree)
            goto errorTreeReturn ;      
        }
        LLVAL(tree) = 1;
+       
+       propAsgType(tree);
+       
        return tree ;
 
     case AND_ASSIGN:
@@ -2443,6 +2596,9 @@ ast *decorateType (ast *tree)
            goto errorTreeReturn ;      
        }
        LLVAL(tree) = 1;
+       
+       propAsgType(tree);
+       
        return tree ;
        
        /*------------------------------------------------------------------*/
@@ -2474,6 +2630,9 @@ ast *decorateType (ast *tree)
            goto errorTreeReturn ;      
        }
        LLVAL(tree) = 1;
+       
+       propAsgType(tree);
+       
        return tree;
        
        /*------------------------------------------------------------------*/
@@ -2512,6 +2671,9 @@ ast *decorateType (ast *tree)
 
        tree->right = decorateType(newNode('+',copyAst(tree->left),tree->right));
        tree->opval.op = '=';       
+       
+       propAsgType(tree);
+       
        return tree;
        
        /*------------------------------------------------------------------*/
@@ -2564,6 +2726,8 @@ ast *decorateType (ast *tree)
            goto errorTreeReturn ;      
        }
 
+        propAsgType(tree);
+
        return tree ;
        
        /*------------------------------------------------------------------*/
@@ -2617,12 +2781,21 @@ ast *decorateType (ast *tree)
        }
        
        /* if there is going to be a casing required then add it */
-       if (checkType(currFunc->type->next,RTYPE(tree)) < 0 ) {
-           tree->right = 
+       if (checkType(currFunc->type->next,RTYPE(tree)) < 0 ) 
+       {
+#ifdef DEMAND_INTEGER_PROMOTION        
+           if (IS_INTEGRAL(currFunc->type->next))
+           {
+               pushTypeCastToLeaves(currFunc->type->next, tree->right, &(tree->right));
+           }
+           else
+#endif     
+           {
+               tree->right = 
                decorateType(newNode(CAST,
-                                    newAst(EX_LINK,
-                                           copyLinkChain(currFunc->type->next)),
+                                    newAst_LINK(copyLinkChain(currFunc->type->next)),
                                     tree->right));
+           }
        }
        
        RRVAL(tree) = 1;
@@ -2709,7 +2882,7 @@ ast *decorateType (ast *tree)
 /*-----------------------------------------------------------------*/
 /* sizeofOp - processes size of operation                          */
 /*-----------------------------------------------------------------*/
-value  *sizeofOp( link  *type)
+value  *sizeofOp( sym_link  *type)
 {
        char buff[10];
 
@@ -2793,14 +2966,20 @@ ast *backPatchLabels (ast *tree, symbol *trueLabel, symbol *falseLabel )
     
     /* change not */
     if (IS_NOT(tree)) {
+       int wasnot = IS_NOT(tree->left);
        tree->left = backPatchLabels (tree->left,falseLabel,trueLabel);
        
        /* if the left is already a IFX */
        if ( ! IS_IFX(tree->left) ) 
            tree->left = newNode (IFX,tree->left,NULL);
        
-       tree->left->trueLabel = falseLabel ;
-       tree->left->falseLabel= trueLabel ;
+       if (wasnot) {
+           tree->left->trueLabel = trueLabel ;
+           tree->left->falseLabel= falseLabel ;
+       } else {
+           tree->left->trueLabel = falseLabel ;
+           tree->left->falseLabel= trueLabel ;
+       }
        return tree->left ;
     }
     
@@ -2862,7 +3041,7 @@ ast  *createLabel  ( symbol  *label,  ast  *stmnt  )
     
     label->islbl = 1;
     label->key = labelKey++ ;
-    rValue =  newNode (LABEL,newAst(EX_VALUE,symbolVal(label)),stmnt);  
+    rValue =  newNode (LABEL,newAst_VALUE(symbolVal(label)),stmnt);  
     rValue->lineno = 0;
     
     return rValue ;
@@ -2995,7 +3174,7 @@ ast *createIf ( ast *condAst, ast *ifBody, ast *elseBody )
     if ( elseBody ) {
        ifBody = newNode(NULLOP,ifBody,
                         newNode(GOTO,
-                                newAst(EX_VALUE,symbolVal(ifEnd)),             
+                                newAst_VALUE(symbolVal(ifEnd)),
                                 NULL));
        /* put the elseLabel on the else body */
        elseBody = createLabel (ifFalse,elseBody);
@@ -3112,7 +3291,7 @@ ast *createFor ( symbol *trueLabel, symbol *continueLabel ,
                           newNode(NULLOP,
                                   loopExpr,
                                   newNode(GOTO,
-                                          newAst(EX_VALUE,symbolVal(condLabel)),
+                                          newAst_VALUE(symbolVal(condLabel)),
                                           NULL)));
     /* now start putting them together */
     forTree = newNode(NULLOP,initExpr,condExpr);
@@ -3155,8 +3334,7 @@ ast *createWhile (symbol *trueLabel, symbol *continueLabel,
     whileBody = newNode(NULLOP,
                        whileBody,
                        newNode(GOTO,
-                               newAst(EX_VALUE,
-                                      symbolVal(continueLabel)),
+                               newAst_VALUE(symbolVal(continueLabel)),
                                createLabel(falseLabel,NULL)));
     
     /* put it all together */
@@ -3374,12 +3552,12 @@ ast  *optimizeCompare ( ast *root )
        case '>' :
        case '<' :
        case NE_OP :
-           optExpr = newAst(EX_VALUE,constVal("0"));
+           optExpr = newAst_VALUE(constVal("0"));
            break;
        case GE_OP :
        case LE_OP :
        case EQ_OP :
-           optExpr = newAst(EX_VALUE,constVal("1"));
+           optExpr = newAst_VALUE(constVal("1"));
            break;
        }
 
@@ -3415,16 +3593,16 @@ ast  *optimizeCompare ( ast *root )
                
            case '<' : /* bit value < 1 means 0 */
            case NE_OP :
-               optExpr = newNode('!',newAst(EX_VALUE,vleft),NULL);
+               optExpr = newNode('!',newAst_VALUE(vleft),NULL);
                break;
                
            case LE_OP : /* bit value <= 1 means no check */
-               optExpr = newAst(EX_VALUE,vright);              
+               optExpr = newAst_VALUE(vright);         
                break;
                
            case GE_OP : /* bit value >= 1 means only check for = */
            case EQ_OP :
-               optExpr = newAst(EX_VALUE,vleft);               
+               optExpr = newAst_VALUE(vleft);          
                break;
            }
        } else { /* literal is zero */
@@ -3436,7 +3614,7 @@ ast  *optimizeCompare ( ast *root )
                
            case '>' : /* bit value > 0 means 1 */
            case NE_OP :
-               optExpr = newAst(EX_VALUE,vleft);            
+               optExpr = newAst_VALUE(vleft);       
                break;
                
            case LE_OP : /* bit value <= 0 means no check */
@@ -3446,7 +3624,7 @@ ast  *optimizeCompare ( ast *root )
                break;
                
            case EQ_OP : /* bit == 0 means ! of bit */
-               optExpr = newNode('!',newAst(EX_VALUE,vleft),NULL);           
+               optExpr = newNode('!',newAst_VALUE(vleft),NULL);              
                break;
            }
        }                      
@@ -3517,7 +3695,7 @@ ast  *createFunction   (symbol  *name,   ast  *body )
     ast  *ex ;
     symbol *csym;
     int stack = 0 ;
-    link *fetype;       
+    sym_link *fetype;       
     iCode *piCode = NULL;
     
     /* if check function return 0 then some problem */
@@ -3537,8 +3715,9 @@ ast  *createFunction   (symbol  *name,   ast  *body )
           we need to add the name to the publics list : this
           actually means we are now compiling the compiler
           support routine */
-       if (name->cdef)
+       if (name->cdef) {
            addSet(&publics,name);
+       }
     }
     else {
        addSymChain(name);
@@ -3587,7 +3766,7 @@ ast  *createFunction   (symbol  *name,   ast  *body )
     body = resolveSymbols(body); /* resolve the symbols */
     body = decorateType (body);  /* propagateType & do semantic checks */
     
-    ex = newAst (EX_VALUE, symbolVal(name));    /* create name       */
+    ex = newAst_VALUE(symbolVal(name));    /* create name       */
     ex = newNode (FUNCTION,ex,body);
     ex->values.args = name->args ;
     
@@ -3632,7 +3811,7 @@ ast  *createFunction   (symbol  *name,   ast  *body )
     addSet(&operKeyReset,name);
     applyToSet(operKeyReset,resetParmKey);
        
-    if (options.debug)
+    if (options.debug && !options.nodebug)
        cdbStructBlock(1,cdbFile);
 
     cleanUpLevel(LabelTab,0);