* src/SDCCpeeph.c (peepHole): Fixed all leaks. Added trace support for freeing...
[fw/sdcc] / src / SDCCast.c
index 09ad2b53b5430271b86d47bd3b47d3c4b978521d..235ee0376df623e51d8ccc51e1c871825af84b2f 100644 (file)
@@ -23,7 +23,6 @@
 -------------------------------------------------------------------------*/
 
 #include "common.h"
-#include "newalloc.h"
 
 int currLineno = 0;
 set *astList = NULL;
@@ -75,7 +74,7 @@ newAst (int type, void *op)
   ast *ex;
   static int oldLineno = 0;
 
-  Safe_calloc (1, ex, sizeof (ast));
+  ex = Safe_alloc ( sizeof (ast));
 
   ex->type = type;
   ex->lineno = (noLineno ? oldLineno : yylineno);
@@ -110,7 +109,7 @@ newAst_ (unsigned type)
   ast *ex;
   static int oldLineno = 0;
 
-  ex = Safe_calloc (1, sizeof (ast));
+  ex = Safe_alloc ( sizeof (ast));
 
   ex->type = type;
   ex->lineno = (noLineno ? oldLineno : yylineno);
@@ -221,7 +220,7 @@ copyAstValues (ast * dest, ast * src)
       break;
 
     case INLINEASM:
-      dest->values.inlineasm = Safe_calloc (1, strlen (src->values.inlineasm) + 1);
+      dest->values.inlineasm = Safe_alloc (strlen (src->values.inlineasm) + 1);
       strcpy (dest->values.inlineasm, src->values.inlineasm);
       break;
 
@@ -252,7 +251,7 @@ copyAst (ast * src)
   if (!src)
     return NULL;
 
-  dest = Safe_calloc (1, sizeof (ast));
+  dest = Safe_alloc ( sizeof (ast));
 
   dest->type = src->type;
   dest->lineno = src->lineno;
@@ -634,9 +633,9 @@ processParms (ast * func,
 
   /* if defined parameters ended but actual parameters */
   /* exist and this is not defined as a variable arg   */
-  /* also check if statckAuto option is specified      */
-  if ((!defParm) && actParm && (!func->hasVargs) &&
-      !options.stackAuto && !IS_RENT (fetype))
+  /* also check if statckAuto option is specified      */ // jwk: WHY?
+  if ((!defParm) && actParm && (!func->hasVargs) 
+      /* && !options.stackAuto && !IS_RENT (fetype) */)
     {
       werror (E_TOO_MANY_PARMS);
       return 1;
@@ -745,13 +744,14 @@ processParms (ast * func,
 
   /* the parameter type must be at least castable */
   if (compareType (defParm->type, actParm->ftype) == 0) {
-    werror (W_INCOMPAT_CAST);
+    werror (E_INCOMPAT_TYPES);
     fprintf (stderr, "type --> '");
     printTypeChain (actParm->ftype, stderr);
     fprintf (stderr, "' ");
     fprintf (stderr, "assigned to type --> '");
     printTypeChain (defParm->type, stderr);
     fprintf (stderr, "'\n");
+    return 1;
   }
 
   /* if the parameter is castable then add the cast */
@@ -2082,7 +2082,7 @@ decorateType (ast * tree)
       {
        sym_link *ltc = (tree->right ? RTYPE (tree) : LTYPE (tree));
        COPYTYPE (TTYPE (tree), TETYPE (tree), ltc);
-       if (!tree->initMode && IS_CONSTANT (TETYPE (tree)))
+       if (!tree->initMode && IS_CONSTANT(TETYPE(tree)))
          werror (E_CODE_WRITE, "++/--");
 
        if (tree->right)
@@ -2732,7 +2732,7 @@ decorateType (ast * tree)
       /* make sure the type is complete and sane */
       checkTypeSanity(LETYPE(tree), "(cast)");
 
-#if 1
+#if 0
       /* if the right is a literal replace the tree */
       if (IS_LITERAL (RETYPE (tree))) {
              if (!IS_PTR (LTYPE (tree))) {
@@ -3106,22 +3106,13 @@ decorateType (ast * tree)
          fprintf (stderr, "'\n");
        }
 
-      /* extra checks for pointer types */
-      if (IS_PTR (LTYPE (tree)) && IS_PTR (RTYPE (tree)) &&
-         !IS_GENPTR (LTYPE (tree)))
-       {
-         if (DCL_TYPE (LTYPE (tree)) != DCL_TYPE (RTYPE (tree)))
-           werror (W_PTR_ASSIGN);
-       }
-
       TETYPE (tree) = getSpec (TTYPE (tree) =
                               LTYPE (tree));
       RRVAL (tree) = 1;
       LLVAL (tree) = 1;
       if (!tree->initMode ) {
-             if (IS_CONSTANT (LETYPE (tree))) {
-                     werror (E_CODE_WRITE, " ");
-             } 
+       if ((IS_SPEC(LETYPE(tree)) && IS_CONSTANT (LETYPE (tree))))
+         werror (E_CODE_WRITE, " ");
       }
       if (LRVAL (tree))
        {