* src/SDCCsymt.h,
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 12 Aug 2004 02:32:05 +0000 (02:32 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 12 Aug 2004 02:32:05 +0000 (02:32 +0000)
* 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
src/SDCCast.c
src/SDCCicode.c
src/SDCCsymt.c
src/SDCCsymt.h
src/SDCCval.c

index dc6923d11dd09eab9dd39a44920c27383843c0d2..6128f49446d065b092df399f90d82a218f9c61b0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2004-08-12 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+       * 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 <slade_rich AT users.sourceforge.net>
 
        * src/pic/glue.c: Added struct initialisation fn printIvalStruct.
index 7769a8183f215b0cafdfe37996376903e302dd23..46b4466e1a60dfd7df216aff84a9d175ff31a4ce 100644 (file)
@@ -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 */
index cc530311e7077b22d4cd0bb37156f421fb4a083d..f65162404b713092cb5b2c5969f352e082b23e8f 100644 (file)
@@ -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
index b621774b9c7476cef7823c6c55b945b0ad655d8c..0ee5bccb69337ffc13be267d812fac7acc6d6acc 100644 (file)
@@ -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;
index 318c2efb295d28d0d7673fc17af59141cb755c7c..c24d6d99304fc7a7fc926ce1178bce390fe2d225 100644 (file)
@@ -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);
index 6b18f5ea2815b08c7c1d0b3692e0989e3a1d8baf..69aab095c2031230256e3436672010820f19a5aa 100644 (file)
@@ -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 */