From a5f1954d67c5525c090e54776f564aec6d37b05a Mon Sep 17 00:00:00 2001 From: MaartenBrock Date: Thu, 15 Nov 2007 17:24:27 +0000 Subject: [PATCH] * 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 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4965 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 8 +++++++- device/include/stdarg.h | 8 ++++---- src/SDCCsymt.c | 40 ++++++++++++++++++++++++---------------- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 56ced7a9..11317a60 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-11-15 Maarten Brock + + * 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 * 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 +2007-11-11 Maarten Brock * as/hc08/asmain.c, * as/z80/asmain.c: cosmetic changes diff --git a/device/include/stdarg.h b/device/include/stdarg.h index fcb5ed58..db0b889c 100644 --- a/device/include/stdarg.h +++ b/device/include/stdarg.h @@ -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 diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 1995e05c..9257c4d2 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -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) -- 2.47.2