fixed bug #485513, although a warning should be thrown for non-constant initializers
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 1 Dec 2001 16:11:23 +0000 (16:11 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 1 Dec 2001 16:11:23 +0000 (16:11 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1656 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCast.c
src/ds390/gen.c
src/mcs51/gen.c
src/pic/gen.c
support/Util/SDCCerr.c

index 05db77f88062641f72ebedacfe9bbcdbb688d2cd..f5e17f81085b57c0d2e8ea85e6e56187831f91d8 100644 (file)
@@ -1124,11 +1124,6 @@ gatherAutoInit (symbol * autoChain)
        {
          symbol *newSym;
          
-         // this can only be a constant
-         if (!inInitMode && !IS_LITERAL(sym->ival->init.node->etype)) {
-           werror (E_CONST_EXPECTED);
-         }
-
          /* insert the symbol into the symbol table */
          /* with level = 0 & name = rname       */
          newSym = copySymbol (sym);
@@ -1830,48 +1825,6 @@ reverseLoop (ast * loop, symbol * sym, ast * init, ast * end)
 
 }
 
-//#define DEMAND_INTEGER_PROMOTION
-
-#ifdef DEMAND_INTEGER_PROMOTION
-
-/*-----------------------------------------------------------------*/
-/* walk a tree looking for the leaves. Add a typecast to the given */
-/* type to each value leaf node.           */
-/*-----------------------------------------------------------------*/
-void 
-pushTypeCastToLeaves (sym_link * type, ast * node, ast ** parentPtr)
-{
-  if (!node || IS_CALLOP(node))
-    {
-      /* WTF? We should never get here. */
-      return;
-    }
-
-  if (!node->left && !node->right)
-    {
-      /* We're at a leaf; if it's a value, apply the typecast */
-      if (node->type == EX_VALUE && IS_INTEGRAL (TTYPE (node)))
-       {
-         *parentPtr = decorateType (newNode (CAST,
-                                        newAst_LINK (copyLinkChain (type)),
-                                             node));
-       }
-    }
-  else
-    {
-      if (node->left)
-       {
-         pushTypeCastToLeaves (type, node->left, &(node->left));
-       }
-      if (node->right)
-       {
-         pushTypeCastToLeaves (type, node->right, &(node->right));
-       }
-    }
-}
-
-#endif
-
 /*-----------------------------------------------------------------*/
 /* decorateType - compute type for this tree also does type cheking */
 /*          this is done bottom up, since type have to flow upwards */
@@ -4294,10 +4247,6 @@ createFunction (symbol * name, ast * body)
   name->lastLine = yylineno;
   currFunc = name;
 
-#if 0 // jwk: this is now done in addDecl()
-  processFuncArgs (currFunc);
-#endif
-
   /* set the stack pointer */
   /* PENDING: check this for the mcs51 */
   stackPtr = -port->stack.direction * port->stack.call_overhead;
index d01c1d7e1396d269e28e7fb0f8fe295bc33e1539..9db62c56fb76c3b536565bb9939fa58f8d14976e 100644 (file)
@@ -2269,7 +2269,7 @@ genCall (iCode * ic)
      the same register bank then we need to save the
      destination registers on the stack */
   dtype = operandType (IC_LEFT (ic));
-  if (dtype && !IFFUNC_ISNAKED(dtype) &&
+  if (currFunc && dtype && !IFFUNC_ISNAKED(dtype) &&
       (FUNC_REGBANK (currFunc->type) != FUNC_REGBANK (dtype)) &&
       IFFUNC_ISISR (currFunc->type))
   {
@@ -2479,7 +2479,7 @@ genPcall (iCode * ic)
      the same register bank then we need to save the
      destination registers on the stack */
   dtype = operandType (IC_LEFT (ic));
-  if (dtype && !IFFUNC_ISNAKED(dtype) &&
+  if (currFunc && dtype && !IFFUNC_ISNAKED(dtype) &&
       IFFUNC_ISISR (currFunc->type) &&
       (FUNC_REGBANK (currFunc->type) != FUNC_REGBANK (dtype))) {
     saveRBank (FUNC_REGBANK (dtype), ic, TRUE);
index 6ea17c482f7864b701db871d101b18b5d35e52b4..7a2c5f303feaa5b4056041539b3026d67b9944bd 100644 (file)
@@ -1925,7 +1925,7 @@ genCall (iCode * ic)
      the same register bank then we need to save the
      destination registers on the stack */
   dtype = operandType (IC_LEFT (ic));
-  if (dtype && !IFFUNC_ISNAKED(dtype) &&
+  if (currFunc && dtype && !IFFUNC_ISNAKED(dtype) &&
       (FUNC_REGBANK (currFunc->type) != FUNC_REGBANK (dtype)) &&
       IFFUNC_ISISR (currFunc->type))
   {
@@ -2023,7 +2023,7 @@ genPcall (iCode * ic)
      the same register bank then we need to save the
      destination registers on the stack */
   dtype = operandType (IC_LEFT (ic));
-  if (dtype && !FUNC_ISNAKED(dtype) &&
+  if (currFunc && dtype && !FUNC_ISNAKED(dtype) &&
       IFFUNC_ISISR (currFunc->type) &&
       (FUNC_REGBANK (currFunc->type) != FUNC_REGBANK (dtype))) {
     saveRBank (FUNC_REGBANK (dtype), ic, TRUE);
@@ -2568,7 +2568,6 @@ genEndFunction (iCode * ic)
        emitcode ("setb", "ea");
 
       /* if debug then send end of function */
-      /*  if (options.debug && currFunc)  */
       if (options.debug && currFunc)
        {
          _G.debugLine = 1;
@@ -8788,7 +8787,6 @@ gen51Code (iCode * lic)
   if (allocInfo)
     printAllocInfo (currFunc, codeOutFile);
   /* if debug information required */
-  /*     if (options.debug && currFunc) { */
   if (options.debug && currFunc)
     {
       cdbSymbol (currFunc, cdbFile, FALSE, TRUE);
index 19197447f45caff3e43d9342c92966e8cd16a82e..50f5c8672fc29f6011af585e1c68bbe49a73a8fd 100644 (file)
@@ -1898,7 +1898,7 @@ static void saveRegisters(iCode *lic)
        }
 
     dtype = operandType(IC_LEFT(ic));
-    if (dtype        && 
+    if (currFunc && dtype && 
         (FUNC_REGBANK(currFunc->type) != FUNC_REGBANK(dtype)) &&
        IFFUNC_ISISR(currFunc->type) &&
         !ic->bankSaved) 
@@ -2189,7 +2189,7 @@ static void genCall (iCode *ic)
      the same register bank then we need to save the
      destination registers on the stack */
   dtype = operandType(IC_LEFT(ic));
-  if (dtype        && 
+  if (currFunc && dtype && 
       (FUNC_REGBANK(currFunc->type) != FUNC_REGBANK(dtype)) &&
       IFFUNC_ISISR(currFunc->type) &&
       !ic->bankSaved) 
@@ -2322,7 +2322,7 @@ static void genPcall (iCode *ic)
     the same register bank then we need to save the
     destination registers on the stack */
     dtype = operandType(IC_LEFT(ic));
-    if (dtype        && 
+    if (currFunc && dtype && 
        IFFUNC_ISISR(currFunc->type) &&
         (FUNC_REGBANK(currFunc->type) != FUNC_REGBANK(dtype)))
         saverbank(FUNC_REGBANK(dtype),ic,TRUE);
@@ -2404,7 +2404,7 @@ static void genPcall (iCode *ic)
     }
 
     /* if register bank was saved then unsave them */
-    if (dtype        && 
+    if (currFunc && dtype && 
         (FUNC_REGBANK(currFunc->type) != FUNC_REGBANK(dtype)))
         unsaverbank(FUNC_REGBANK(dtype),ic,TRUE);
 
index ed6eebd678d7a5279d16408cae9c64657cb1240a..f40432d9e0f444af7b275fdf10973cf103511aee 100644 (file)
@@ -54,7 +54,7 @@ struct
 { E_SYNTAX_ERROR, ERROR_LEVEL_ERROR,
    "Syntax error, declaration ignored at '%s'" },
 { E_CONST_EXPECTED, ERROR_LEVEL_ERROR,
-   "Constant Expected Found Variable" },
+    "Initializer element is not constant" },
 { E_OUT_OF_MEM, ERROR_LEVEL_ERROR,
    "'malloc' failed file '%s' for size %ld" },
 { E_FILE_OPEN_ERR, ERROR_LEVEL_ERROR,