]> git.gag.com Git - fw/sdcc/commitdiff
fixed an array to pointer bug
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 29 Oct 2001 10:29:22 +0000 (10:29 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 29 Oct 2001 10:29:22 +0000 (10:29 +0000)
cleaned it up a little
unified print from -> to typechain

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1462 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCast.c
src/SDCCicode.c
src/SDCCsymt.c
src/SDCCsymt.h

index 2cc429de7c11f1f68b4bfc367e218e7d74aa9eab..aa9927106bcbbb29069f7ba8641f924a1a55cd5f 100644 (file)
@@ -739,12 +739,7 @@ processParms (ast * func,
   /* the parameter type must be at least castable */
   if (compareType (defParm->type, actParm->ftype) == 0) {
     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");
+    printFromToType (actParm->ftype, defParm->type);
     return 1;
   }
 
@@ -791,6 +786,7 @@ ast *
 createIvalStruct (ast * sym, sym_link * type, initList * ilist)
 {
   ast *rast = NULL;
+  ast *lAst;
   symbol *sflds;
   initList *iloop;
 
@@ -805,8 +801,6 @@ createIvalStruct (ast * sym, sym_link * type, initList * ilist)
 
   for (; sflds; sflds = sflds->next, iloop = (iloop ? iloop->next : NULL))
     {
-      ast *lAst;
-
       /* if we have come to end */
       if (!iloop)
        break;
@@ -3052,12 +3046,7 @@ decorateType (ast * tree)
       if (IS_VOID (LTYPE (tree)))
        {
          werror (E_CAST_ZERO);
-         fprintf (stderr, "type --> '");
-         printTypeChain (RTYPE (tree), stderr);
-         fprintf (stderr, "' ");
-         fprintf (stderr, "assigned to type --> '");
-         printTypeChain (LTYPE (tree), stderr);
-         fprintf (stderr, "'\n");
+         printFromToType(RTYPE(tree), LTYPE(tree));
        }
 
       TETYPE (tree) = getSpec (TTYPE (tree) =
@@ -3117,11 +3106,7 @@ decorateType (ast * tree)
       if (compareType (currFunc->type->next, RTYPE (tree)) == 0)
        {
          werror (W_RETURN_MISMATCH);
-         fprintf (stderr, "from type '");
-         printTypeChain (RTYPE(tree), stderr);
-         fprintf (stderr, "' to type '");
-         printTypeChain (currFunc->type->next, stderr);
-         fprintf (stderr, "'\n");
+         printFromToType (RTYPE(tree), currFunc->type->next);
          goto errorTreeReturn;
        }
 
index fc950632316409ac51307900989e6cdaff7aa0fd..297ed3a7954ac7ac98f4a546b150a4e696a94626 100644 (file)
@@ -1658,13 +1658,7 @@ geniCodeCast (sym_link * type, operand * op, bool implicit)
     }
   }
   if (errors) {
-    /* fprintf (stderr, "%s%s %d: ", op->operand.symOperand->name,
-       implicit?"(implicit)":"", errors); */
-    fprintf (stderr, "from type '");
-    printTypeChain (optype, stderr);
-    fprintf (stderr, "' to type '");
-    printTypeChain (type, stderr);
-    fprintf (stderr, "'\n");
+    printFromToType (optype, type);
   }
 
   /* if they are the same size create an assignment */
@@ -2118,8 +2112,10 @@ geniCodeStruct (operand * left, operand * right, bool islval)
   SPEC_OCLS (retype) = SPEC_OCLS (etype);
   SPEC_VOLATILE (retype) |= SPEC_VOLATILE (etype);
 
+#if 1 // jwk
   if (IS_PTR (element->type))
     setOperandType (IC_RESULT (ic), aggrToPtr (operandType (IC_RESULT (ic)), TRUE));
+#endif
 
   IC_RESULT (ic)->isaddr = (!IS_AGGREGATE (element->type));
 
@@ -2710,11 +2706,6 @@ geniCodeParms (ast * parms, value *argVals, int *stack,
     argVals=FUNC_ARGS(func->type);
   }
 
-  if (parms->argSym || 
-      (parms->type!=EX_OP && parms->type!=EX_OPERAND)) {
-    fprintf (stderr, "What the fuck??\n");
-  }
-
   /* if this is a param node then do the left & right */
   if (parms->type == EX_OP && parms->opval.op == PARAM)
     {
index e0a94215961d52e8274988f9da47e9e41533aeba..0a5767de762f9a27371adaf43e264adc807af809 100644 (file)
 
 value *aggregateToPointer (value *val);
 
+void printFromToType(sym_link *from, sym_link *to) {
+  fprintf (stderr, "from type '");
+  printTypeChain (from, stderr);
+  fprintf (stderr, "'\nto type '");
+  printTypeChain (to, stderr);
+  fprintf (stderr, "'\n");
+}
+
 /* noun strings */
 char *nounName(sym_link *sl) {
   switch (SPEC_NOUN(sl)) 
@@ -545,10 +553,6 @@ mergeSpec (sym_link * dest, sym_link * src, char *name)
     exit (1);
   }
 
-  if (getenv("DEBUG_mergeSpec")) {
-    fprintf (stderr, "mergeSpec: \"%s\"\n", name);
-  }
-
   if (SPEC_NOUN(src)) {
     if (!SPEC_NOUN(dest)) {
       SPEC_NOUN(dest)=SPEC_NOUN(src);
@@ -1119,9 +1123,6 @@ checkSClass (symbol * sym, int isProto)
   if (getenv("DEBUG_SANITY")) {
     fprintf (stderr, "checkSClass: %s \n", sym->name);
   }
-  if (strcmp(sym->name, "_testsGlobal")==0) {
-    printf ("oach\n");
-  }
   
   /* type is literal can happen foe enums change
      to auto */
@@ -1563,8 +1564,8 @@ aggregateToPointer (value * val)
        case S_FIXED:
          if (SPEC_OCLS(val->etype)) {
            DCL_TYPE(val->type)=PTR_TYPE(SPEC_OCLS(val->etype));
+           break;
          }
-         break;
 
          if (TARGET_IS_DS390)
            {
@@ -1675,12 +1676,7 @@ checkFunction (symbol * sym, symbol *csym)
   if (compareType (csym->type, sym->type) <= 0)
     {
       werror (E_PREV_DEF_CONFLICT, csym->name, "type");
-      werror (W_CONTINUE, "previous definition type ");
-      printTypeChain (csym->type, stderr);
-      fprintf (stderr, "\n");
-      werror (W_CONTINUE, "current definition type ");
-      printTypeChain (sym->type, stderr);
-      fprintf (stderr, "\n");
+      printFromToType(csym->type, sym->type);
       return 0;
     }
 
@@ -1731,6 +1727,7 @@ checkFunction (symbol * sym, symbol *csym)
       if (compareType (exargs->type, checkValue->type) <= 0)
        {
          werror (E_ARG_TYPE, argCnt);
+         printFromToType(exargs->type, checkValue->type);
          return 0;
        }
     }
index 12e76466b49e6be5c17893398f296f0baafbf36c..6ff6e0a72addecde9906c0d4dd7fe5f953c11a28 100644 (file)
@@ -487,7 +487,8 @@ void *findSymWithLevel (bucket **, struct symbol *);
 void *findSymWithBlock (bucket **, struct symbol *, int);
 void changePointer (symbol * sym);
 void checkTypeSanity(sym_link *etype, char *name);
-/* noun strings */
-extern char *nounName(sym_link *);
+
+extern char *nounName(sym_link *); /* noun strings */
+extern void printFromToType (sym_link *, sym_link *);
 
 #endif