* device/include/stdarg.h: added and removed some casts
authorMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 15 Nov 2007 17:24:27 +0000 (17:24 +0000)
committerMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 15 Nov 2007 17:24:27 +0000 (17:24 +0000)
* src/SDCCsymt.c (compareType): Fully check types between generic and
  non-generic pointers, also accept ptr-ptr to void-ptr assignments

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

ChangeLog
device/include/stdarg.h
src/SDCCsymt.c

index 56ced7a924a589110f2cb56c71b32a9dac769851..11317a604ba030e53ad036223b838ebd5c04c318 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-11-15 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * device/include/stdarg.h: added and removed some casts
+       * src/SDCCsymt.c (compareType): Fully check types between generic and
+         non-generic pointers, also accept ptr-ptr to void-ptr assignments
+
 2007-11-13 Borut Razem <borut.razem AT siol.net>
 
        * support/regression/tests/bug-1817005.c:
@@ -9,7 +15,7 @@
          as\z80\asout.c, as\z80\aslist.c:
          fixed bug #1817005 - as-z80 chokes on long labels
 
-2007-11-10 Maarten Brock <sourceforge.brock AT dse.nl>
+2007-11-11 Maarten Brock <sourceforge.brock AT dse.nl>
 
        * as/hc08/asmain.c,
        * as/z80/asmain.c: cosmetic changes
index fcb5ed58a1fa51dea5ae4d2da54c4ddab0948775..db0b889ca0dc65497a93b7afaea5567f876a4aa9 100644 (file)
@@ -8,25 +8,25 @@
 #if defined(__z80) || defined(__gbz80) || defined(__hc08)
 
 typedef unsigned char * va_list;
-#define va_start(marker, last)  { marker = (unsigned char *)&last + sizeof(last); }
+#define va_start(marker, last)  { marker = (va_list)&last + sizeof(last); }
 #define va_arg(marker, type)    *((type *)((marker += sizeof(type)) - sizeof(type)))
 
 #elif defined(__ds390) || defined(__ds400)
 
 typedef unsigned char * va_list;
-#define va_start(marker, first) { marker = &first; }
+#define va_start(marker, first) { marker = (va_list)&first; }
 #define va_arg(marker, type)    *((type *)(marker -= sizeof(type)))
 
 #elif defined(SDCC_USE_XSTACK)
 
 typedef unsigned char __pdata * va_list;
-#define va_start(marker, first) { marker = (va_list)((char __pdata *)&first); }
+#define va_start(marker, first) { marker = (va_list)&first; }
 #define va_arg(marker, type)    *((type __pdata *)(marker -= sizeof(type)))
 
 #else
 
 typedef unsigned char __data * va_list;
-#define va_start(marker, first) { marker = (va_list) ((char __data * )&first); }
+#define va_start(marker, first) { marker = (va_list)&first; }
 #define va_arg(marker, type)    *((type __data * )(marker -= sizeof(type)))
 
 #endif
index 1995e05caab2d89407a117db0d54d9456395bc0c..9257c4d2be55f167ca78dac5080d0d851d28aebb 100644 (file)
@@ -81,7 +81,7 @@ initSymt ()
 
 }
 /*-----------------------------------------------------------------*/
-/* newBucket - allocates & returns a new bucket        */
+/* newBucket - allocates & returns a new bucket                    */
 /*-----------------------------------------------------------------*/
 bucket *
 newBucket ()
@@ -118,7 +118,7 @@ addSym (bucket ** stab,
         int checkType)
 {
   int i;                        /* index into the hash Table */
-  bucket *bp;                   /* temp bucket    *         */
+  bucket *bp;                   /* temp bucket    *          */
 
   if (checkType) {
     symbol *csym = (symbol *)sym;
@@ -141,8 +141,8 @@ addSym (bucket ** stab,
   /* get a free entry */
   bp = Safe_alloc ( sizeof (bucket));
 
-  bp->sym = sym;                /* update the symbol pointer  */
-  bp->level = level;            /* update the nest level      */
+  bp->sym = sym;                /* update the symbol pointer */
+  bp->level = level;            /* update the nest level     */
   bp->block = block;
   strncpyz (bp->name, sname, sizeof(bp->name)); /* copy the name into place */
 
@@ -163,7 +163,7 @@ addSym (bucket ** stab,
 }
 
 /*-----------------------------------------------------------------*/
-/* deleteSym - deletes a symbol from the hash Table  entry     */
+/* deleteSym - deletes a symbol from the hash Table entry          */
 /*-----------------------------------------------------------------*/
 void
 deleteSym (bucket ** stab, void *sym, char *sname)
@@ -203,7 +203,7 @@ deleteSym (bucket ** stab, void *sym, char *sname)
 }
 
 /*-----------------------------------------------------------------*/
-/* findSym - finds a symbol in a table           */
+/* findSym - finds a symbol in a table                             */
 /*-----------------------------------------------------------------*/
 void *
 findSym (bucket ** stab, void *sym, const char *sname)
@@ -690,9 +690,9 @@ mergeSpec (sym_link * dest, sym_link * src, char *name)
   return dest;
 }
 
-/*------------------------------------------------------------------*/
+/*-------------------------------------------------------------------*/
 /* genSymName - generates and returns a name used for anonymous vars */
-/*------------------------------------------------------------------*/
+/*-------------------------------------------------------------------*/
 char *
 genSymName (int level)
 {
@@ -747,7 +747,7 @@ newFloatLink ()
 }
 
 /*------------------------------------------------------------------*/
-/* newFixed16x16Link - a new Float type                                  */
+/* newFixed16x16Link - a new Float type                             */
 /*------------------------------------------------------------------*/
 sym_link *
 newFixed16x16Link ()
@@ -1007,7 +1007,7 @@ copySymbol (symbol * src)
 }
 
 /*------------------------------------------------------------------*/
-/* reverseSyms - reverses the links for a symbol chain      */
+/* reverseSyms - reverses the links for a symbol chain              */
 /*------------------------------------------------------------------*/
 symbol *
 reverseSyms (symbol * sym)
@@ -1032,7 +1032,7 @@ reverseSyms (symbol * sym)
 }
 
 /*------------------------------------------------------------------*/
-/* reverseLink - reverses the links for a type chain        */
+/* reverseLink - reverses the links for a type chain                */
 /*------------------------------------------------------------------*/
 sym_link *
 reverseLink (sym_link * type)
@@ -1685,14 +1685,14 @@ changePointer (sym_link * p)
 }
 
 /*------------------------------------------------------------------*/
-/* checkDecl - does semantic validation of a declaration                   */
+/* checkDecl - does semantic validation of a declaration            */
 /*------------------------------------------------------------------*/
 int
 checkDecl (symbol * sym, int isProto)
 {
 
-  checkSClass (sym, isProto);           /* check the storage class      */
-  changePointer (sym->type);          /* change pointers if required */
+  checkSClass (sym, isProto);        /* check the storage class     */
+  changePointer (sym->type);         /* change pointers if required */
 
   /* if this is an array without any dimension
      then update the dimension from the initial value */
@@ -2090,7 +2090,12 @@ compareType (sym_link * dest, sym_link * src)
               (IS_GENPTR (dest) ||
                ((DCL_TYPE(src) == POINTER) && (DCL_TYPE(dest) == IPOINTER))
              ))
-            return -1;
+            {
+              if (compareType (dest->next, src->next))
+                return -1;
+              else
+                return 0;
+            }
           if (IS_PTR (dest) && IS_ARRAY (src))
             {
               value *val=aggregateToPointer (valFromType(src));
@@ -2109,6 +2114,9 @@ compareType (sym_link * dest, sym_link * src)
         return 0;
     }
 
+  if (IS_PTR (src) && IS_VOID (dest))
+    return -1;
+
   /* if one is a specifier and the other is not */
   if ((IS_SPEC (src) && !IS_SPEC (dest)) ||
       (IS_SPEC (dest) && !IS_SPEC (src)))
@@ -2343,7 +2351,7 @@ compareTypeExact (sym_link * dest, sym_link * src, int level)
 }
 
 /*------------------------------------------------------------------*/
-/* inCalleeSaveList - return 1 if found in callee save list          */
+/* inCalleeSaveList - return 1 if found in callee save list         */
 /*------------------------------------------------------------------*/
 static int
 calleeCmp(void *p1, void *p2)