]> git.gag.com Git - fw/sdcc/commitdiff
Changelog:1.102 I hate to repeat myself ...
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 3 Mar 2002 17:45:50 +0000 (17:45 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 3 Mar 2002 17:45:50 +0000 (17:45 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1989 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCast.c
src/SDCCglue.c
support/Util/SDCCerr.c
support/Util/SDCCerr.h
support/regression/tests/bug-524691.c

index a647dcddb0dc05aab8a07db8107a84087ae28554..e66872b303c1060f6789a0642a2152b891ab2994 100644 (file)
@@ -367,6 +367,7 @@ resolveSymbols (ast * tree)
   if (tree == NULL)
     return tree;
 
+#if 0
   /* print the line          */
   /* if not block & function */
   if (tree->type == EX_OP &&
@@ -377,6 +378,7 @@ resolveSymbols (ast * tree)
       filename = tree->filename;
       lineno = tree->lineno;
     }
+#endif
 
   /* make sure we resolve the true & false labels for ifx */
   if (tree->type == EX_OP && tree->opval.op == IFX)
@@ -1085,6 +1087,16 @@ gatherAutoInit (symbol * autoChain)
       /* if there is an initial value */
       if (sym->ival && SPEC_SCLS (sym->etype) != S_CODE)
        {
+         initList *ilist=sym->ival;
+         
+         while (ilist->type == INIT_DEEP) {
+           ilist = ilist->init.deep;
+         }
+
+         /* update lineno for error msg */
+         lineno=sym->lineDef;
+         setAstLineno (ilist->init.node, lineno);
+         
          if (IS_AGGREGATE (sym->type)) {
            work = initAggregates (sym, sym->ival, NULL);
          } else {
@@ -1095,8 +1107,10 @@ gatherAutoInit (symbol * autoChain)
            work = newNode ('=', newAst_VALUE (symbolVal (sym)),
                            list2expr (sym->ival));
          }
-
+         
+         // just to be sure
          setAstLineno (work, sym->lineDef);
+
          sym->ival = NULL;
          if (init)
            init = newNode (NULLOP, init, work);
@@ -1849,6 +1863,7 @@ decorateType (ast * tree)
 
   tree->decorated = 1;
 
+#if 0
   /* print the line          */
   /* if not block & function */
   if (tree->type == EX_OP &&
@@ -1859,6 +1874,7 @@ decorateType (ast * tree)
       filename = tree->filename;
       lineno = tree->lineno;
     }
+#endif
 
   /* if any child is an error | this one is an error do nothing */
   if (tree->isError ||
@@ -2454,7 +2470,7 @@ decorateType (ast * tree)
 
       LRVAL (tree) = RRVAL (tree) = 1;
       /* if the left is a pointer */
-      if (IS_PTR (LTYPE (tree)))
+      if (IS_PTR (LTYPE (tree)) || IS_ARRAY (LTYPE (tree)))
        TETYPE (tree) = getSpec (TTYPE (tree) =
                                 LTYPE (tree));
       else
index 7bb11bef41e1d86703e09cdf3b31c7b92a506b52..b0860486c8d8e86acd7dc3695fc7e30f0dca7672 100644 (file)
@@ -329,11 +329,23 @@ initPointer (initList * ilist, sym_link *toType)
        if ((val = constExprValue (expr, FALSE)))
                return val;
        
+       /* ( ptr + constant ) */
+       if (IS_AST_OP (expr) &&
+           (expr->opval.op == '+' || expr->opval.op == '-') &&
+           IS_AST_SYM_VALUE (expr->left) &&
+           (IS_ARRAY(expr->left->ftype) || IS_PTR(expr->left->ftype)) &&
+           compareType(toType, expr->left->ftype) &&
+           IS_AST_LIT_VALUE (expr->right)) {
+         return valForCastAggr (expr->left, expr->left->ftype,
+                                     expr->right,
+                                     expr->opval.op);
+       }
+       
        /* (char *)&a */
        if (IS_AST_OP(expr) && expr->opval.op==CAST &&
            IS_AST_OP(expr->right) && expr->right->opval.op=='&') {
          if (compareType(toType, expr->left->ftype)!=1) {
-           werror (E_INIT_WRONG);
+           werror (W_INIT_WRONG);
            printFromToType(expr->left->ftype, toType);
          }
          // skip the cast ???
@@ -401,7 +413,6 @@ initPointer (initList * ilist, sym_link *toType)
                                       expr->right, expr->opval.op);
 
        }
-       
        /* case 4. (char *)(array type) */
        if (IS_CAST_OP(expr) && IS_AST_SYM_VALUE (expr->right) &&
            IS_ARRAY(expr->right->ftype)) {
@@ -427,7 +438,7 @@ initPointer (initList * ilist, sym_link *toType)
                return val;
        }
  wrong:
-       werror (E_INIT_WRONG);
+       werror (E_INCOMPAT_PTYPES);
        return NULL;
 
 }
@@ -493,12 +504,8 @@ pointerTypeToGPByte (const int p_type, const char *iname, const char *oname)
     case POINTER:
       return 0;
     case GPOINTER:
-      /* hack - if we get a generic pointer, we just assume
-       * it's an FPOINTER (i.e. in XDATA space).
-       */
       werror (E_CANNOT_USE_GENERIC_POINTER, iname, oname);
       exit (1);
-      // fall through
     case FPOINTER:
       return 1;
     case CPOINTER:
@@ -971,7 +978,7 @@ printIvalPtr (symbol * sym, sym_link * type, initList * ilist, FILE * oFile)
 
   /* check the type      */
   if (compareType (type, val->type) == 0) {
-    werror (E_INIT_WRONG);
+    werror (W_INIT_WRONG);
     printFromToType (val->type, type);
   }
 
index e8b25529f1c21450822283324cc2e96d94c293c2..5aac4a73a2f00ece48a41172fdf0ad47bc31987e 100644 (file)
@@ -87,7 +87,7 @@ struct
    "storage class not allowed for automatic variable '%s' in reentrant function unless static" },
 { E_AUTO_ABSA, ERROR_LEVEL_ERROR,
    "absolute address not allowed for automatic var '%s' in reentrant function " },
-{ E_INIT_WRONG, ERROR_LEVEL_ERROR,
+{ W_INIT_WRONG, ERROR_LEVEL_WARNING,
    "Initializer different levels of indirections" },
 { E_FUNC_REDEF, ERROR_LEVEL_ERROR,
    "Function name '%s' redefined " },
index f56b728a6429b5ccf42fa8e829af48ea4badadd2..fcd04ea873b4d08b0ea4eaa3bf66a39ba70cada7 100644 (file)
@@ -33,7 +33,7 @@ SDCCERR - SDCC Standard error handler
 #define  W_INIT_IGNORED    15        /* initialiser ignored  */
 #define  E_AUTO_ASSUMED    16        /* sclass auto assumed  */
 #define  E_AUTO_ABSA       17        /* abs addr for auto var*/
-#define  E_INIT_WRONG      18        /* initializer type !=  */
+#define  W_INIT_WRONG      18        /* initializer type !=  */
 #define  E_FUNC_REDEF      19        /* func name redefined  */
 #define  E_ID_UNDEF        20        /* identifer undefined  */
 #define  W_STACK_OVERFLOW  21        /* stack overflow       */
index a4442382b69065deea29919ca707e9a367d9cf68..8b0a3db74749d3d905b08d93bc4c35ec2052f5c5 100644 (file)
@@ -2,6 +2,12 @@
  */
 #include <testfwk.h>
 
+#if defined __mcs51 || defined __ds390 || defined __xa51
+#define XDATA xdata
+#else
+#define XDATA
+#endif
+
 typedef unsigned int UINT;
 
 typedef struct _HeapEntryState
@@ -43,9 +49,9 @@ void
 testDivByZero(void)
 {
   HeapEntryState aStates[] = {
-    { (void *)1, 0 }
+    { (void XDATA *)1, 0 }
   };
-  void *p = (void *)0x1234;
+  void *p = (void XDATA *)0x1234;
 
   ASSERT(_getHeapEntryState(p, aStates, 1) == NULL);