From 3d82fa71091d058893f8de85ffb2560a653be90e Mon Sep 17 00:00:00 2001 From: epetrich Date: Thu, 12 Aug 2004 02:32:05 +0000 Subject: [PATCH] * src/SDCCsymt.h, * src/SDCCsymt.c (changePointer, checkDecl, addSymChain): changed parameter of changePointer() from symbol* to sym_link* * src/SDCCast.c (decorateType): call changePointer() for CAST op * src/SDCCsymt.c (compareType): void* type is castable to other pointers, but not necesarily an exact match. * src/SDCCicode.c (geniCodeCast): allow void* casting here since it is no longer blindly treated as an exact match. * src/SDCCval.c (valCastLiteral): treat missing type as cast to void git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3436 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 12 ++++++++++++ src/SDCCast.c | 1 + src/SDCCicode.c | 8 +++++++- src/SDCCsymt.c | 11 +++++------ src/SDCCsymt.h | 2 +- src/SDCCval.c | 8 +++++++- 6 files changed, 33 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc6923d1..6128f494 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2004-08-12 Erik Petrich + + * src/SDCCsymt.h, + * src/SDCCsymt.c (changePointer, checkDecl, addSymChain): changed + parameter of changePointer() from symbol* to sym_link* + * src/SDCCast.c (decorateType): call changePointer() for CAST op + * src/SDCCsymt.c (compareType): void* type is castable to other + pointers, but not necesarily an exact match. + * src/SDCCicode.c (geniCodeCast): allow void* casting here since it + is no longer blindly treated as an exact match. + * src/SDCCval.c (valCastLiteral): treat missing type as cast to void + 2004-08-12 Slade Rich * src/pic/glue.c: Added struct initialisation fn printIvalStruct. diff --git a/src/SDCCast.c b/src/SDCCast.c index 7769a818..46b4466e 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -3466,6 +3466,7 @@ decorateType (ast * tree, RESULT_TYPE resultType) } /* make sure the type is complete and sane */ + changePointer(LTYPE(tree)); checkTypeSanity(LETYPE(tree), "(cast)"); /* If code memory is read only, then pointers to code memory */ diff --git a/src/SDCCicode.c b/src/SDCCicode.c index cc530311..f6516240 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -1919,7 +1919,13 @@ geniCodeCast (sym_link * type, operand * op, bool implicit) } } } else { // from a pointer to a pointer - if (port->s.gptr_size > port->s.fptr_size /*!TARGET_IS_Z80 && !TARGET_IS_GBZ80*/) { + if (IS_GENPTR(type) && IS_VOID(type->next)) + { // cast to void* is always allowed + } + else if (IS_GENPTR(optype) && IS_VOID(optype->next)) + { // cast from void* is always allowed + } + else if (port->s.gptr_size > port->s.fptr_size /*!TARGET_IS_Z80 && !TARGET_IS_GBZ80*/) { // if not a pointer to a function if (!(IS_CODEPTR(type) && IS_FUNC(type->next) && IS_FUNC(optype))) { if (implicit) { // if not to generic, they have to match diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index b621774b..0ee5bccb 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -1013,7 +1013,7 @@ addSymChain (symbol * symHead) for (; sym != NULL; sym = sym->next) { - changePointer(sym); + changePointer(sym->type); checkTypeSanity(sym->etype, sym->name); if (!sym->level && !(IS_SPEC(sym->etype) && IS_TYPEDEF(sym->etype))) @@ -1511,15 +1511,14 @@ checkSClass (symbol * sym, int isProto) /* changePointer - change pointer to functions */ /*------------------------------------------------------------------*/ void -changePointer (symbol * sym) +changePointer (sym_link * p) { - sym_link *p; /* go thru the chain of declarations */ /* if we find a pointer to a function */ /* unconditionally change it to a ptr */ /* to code area */ - for (p = sym->type; p; p = p->next) + for (; p; p = p->next) { if (!IS_SPEC (p) && DCL_TYPE (p) == UPOINTER) DCL_TYPE (p) = port->unqualified_pointer; @@ -1536,7 +1535,7 @@ checkDecl (symbol * sym, int isProto) { checkSClass (sym, isProto); /* check the storage class */ - changePointer (sym); /* change pointers if required */ + changePointer (sym->type); /* change pointers if required */ /* if this is an array without any dimension then update the dimension from the initial value */ @@ -1894,7 +1893,7 @@ compareType (sym_link * dest, sym_link * src) return compareType (dest->next, src->next); } if (IS_PTR (dest) && IS_GENPTR (src) && IS_VOID(src->next)) { - return 1; + return -1; } if (IS_PTR (src) && IS_GENPTR (dest)) return -1; diff --git a/src/SDCCsymt.h b/src/SDCCsymt.h index 318c2efb..c24d6d99 100644 --- a/src/SDCCsymt.h +++ b/src/SDCCsymt.h @@ -576,7 +576,7 @@ void deleteSym (bucket **, void *, char *); void *findSym (bucket **, void *, const char *); void *findSymWithLevel (bucket **, struct symbol *); void *findSymWithBlock (bucket **, struct symbol *, int); -void changePointer (symbol * sym); +void changePointer (sym_link * p); void checkTypeSanity(sym_link *etype, char *name); sym_link *typeFromStr (char *) ; STORAGE_CLASS sclsFromPtr(sym_link *ptr); diff --git a/src/SDCCval.c b/src/SDCCval.c index 6b18f5ea..69aab095 100644 --- a/src/SDCCval.c +++ b/src/SDCCval.c @@ -1560,7 +1560,13 @@ valCastLiteral (sym_link * dtype, double fval) return NULL; val = newValue (); - val->etype = getSpec (val->type = copyLinkChain (dtype)); + if (dtype) + val->etype = getSpec (val->type = copyLinkChain (dtype)); + else + { + val->etype = val->type = newLink (SPECIFIER); + SPEC_NOUN (val->etype) = V_VOID; + } SPEC_SCLS (val->etype) = S_LITERAL; /* if it is not a specifier then we can assume that */ -- 2.30.2