Oops
[fw/sdcc] / src / SDCCast.c
index 644d8fb3ddbafd082976f2cbc064cd712227a11d..1399fbd8b2ffa2fbcafed208873de860c078ef59 100644 (file)
@@ -47,7 +47,7 @@ int labelKey = 1;
 
 int noLineno = 0;
 int noAlloc = 0;
-symbol *currFunc;
+symbol *currFunc=NULL;
 static ast *createIval (ast *, sym_link *, initList *, ast *);
 static ast *createIvalCharPtr (ast *, sym_link *, ast *);
 static ast *optimizeCompare (ast *);
@@ -78,7 +78,7 @@ newAst_ (unsigned type)
   ex = Safe_alloc ( sizeof (ast));
 
   ex->type = type;
-  ex->lineno = (noLineno ? oldLineno : yylineno);
+  ex->lineno = (noLineno ? oldLineno : mylineno);
   ex->filename = currFname;
   ex->level = NestLevel;
   ex->block = currBlockno;
@@ -110,14 +110,6 @@ newAst_LINK (sym_link * val)
   return ex;
 }
 
-ast *
-newAst_STMNT (unsigned val)
-{
-  ast *ex = newAst_ (EX_STMNT);
-  ex->opval.stmnt = val;
-  return ex;
-}
-
 /*-----------------------------------------------------------------*/
 /* newNode - creates a new node                                    */
 /*-----------------------------------------------------------------*/
@@ -1287,6 +1279,8 @@ bool constExprTree (ast *cexpr) {
       if (constExprTree(cexpr->left) && constExprTree(cexpr->right)) {
        return TRUE;
       }
+    case EX_OPERAND:
+      return IS_CONSTANT(operandType(cexpr->opval.oprnd));
     }
   return FALSE;
 }  
@@ -3232,7 +3226,6 @@ decorateType (ast * tree)
        {
          werror (E_TYPE_MISMATCH, "assignment", " ");
          printFromToType(RTYPE(tree),LTYPE(tree));
-         //goto errorTreeReturn;
        }
 
       /* if the left side of the tree is of type void
@@ -3283,12 +3276,15 @@ decorateType (ast * tree)
       if ((options.stackAuto || IFFUNC_ISREENT (LTYPE (tree))) && 
          !IFFUNC_ISBUILTIN(LTYPE(tree)))
        {
-         //FUNC_ARGS(tree->left->ftype) = 
-         //reverseVal (FUNC_ARGS(tree->left->ftype));
          reverseParms (tree->right);
        }
 
-      TETYPE (tree) = getSpec (TTYPE (tree) = LTYPE (tree)->next);
+      if (IS_CODEPTR(LTYPE(tree))) {
+       TTYPE(tree) = LTYPE(tree)->next->next;
+      } else {
+       TTYPE(tree) = LTYPE(tree)->next;
+      }
+      TETYPE (tree) = getSpec (TTYPE (tree));
       return tree;
 
       /*------------------------------------------------------------------*/
@@ -3330,7 +3326,7 @@ decorateType (ast * tree)
 
       if (!IS_VOID (currFunc->type->next) && tree->right == NULL)
        {
-         werror (E_VOID_FUNC, currFunc->name);
+         werror (W_VOID_FUNC, currFunc->name);
          goto errorTreeReturn;
        }
 
@@ -4318,7 +4314,7 @@ createFunction (symbol * name, ast * body)
       addSymChain (name);
       allocVariables (name);
     }
-  name->lastLine = yylineno;
+  name->lastLine = mylineno;
   currFunc = name;
 
   /* set the stack pointer */
@@ -4459,7 +4455,7 @@ void ast_print (ast * tree, FILE *outfile, int indent)
                value *args=FUNC_ARGS(tree->left->opval.val->type);
                fprintf(outfile,"FUNCTION (%s=%p) type (", 
                        tree->left->opval.val->name, tree);
-               printTypeChain (tree->ftype,outfile);
+               printTypeChain (tree->left->opval.val->type->next,outfile);
                fprintf(outfile,") args (");
                do {
                  if (arg) {