* src/SDCCsymt.h,
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 9 Feb 2004 07:06:19 +0000 (07:06 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 9 Feb 2004 07:06:19 +0000 (07:06 +0000)
* src/SDCCicode.c (operandFromSymbol),
* src/mcs51/ralloc.c (verifyRegsAssigned, serialRegAssign),
* src/ds390/ralloc.c (verifyRegsAssigned, serialRegAssign),
* src/z80/ralloc.c (verifyRegsAssigned, serialRegAssign),
* src/hc08/ralloc.c (verifyRegsAssigned, serialRegAssign),
* src/pic/ralloc.c (verifyRegsAssigned, serialRegAssign),
* src/pic16/ralloc.c (verifyRegsAssigned, serialRegAssign): fixed bug #892038
* src/SDCCast.c (createIvalStruct, createIvalArray, gatherAutoInit),
* src/SDCCglue.c (emitRegularMap, printIvalStruct, printIvalArray,
printIvalCharPtr, printIvalPtr, printIval, emitStaticSeg, emitOverlay)
* src/SDCCsymt.c (newSymbol),
* src/SDCC.y (struct_or_union_specifier, enum_specifier,
enumerator_list),
* src/SDCCval.h,
* src/SDCCval.c (newiList): fixed bug #885705

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3183 4a8a32a2-be11-0410-ad9d-d568d2c75423

15 files changed:
ChangeLog
src/SDCC.y
src/SDCCast.c
src/SDCCglue.c
src/SDCCicode.c
src/SDCCsymt.c
src/SDCCsymt.h
src/SDCCval.c
src/SDCCval.h
src/ds390/ralloc.c
src/hc08/ralloc.c
src/mcs51/ralloc.c
src/pic/ralloc.c
src/pic16/ralloc.c
src/z80/ralloc.c

index cdf42439192248adb14f6cb03c497d0b41ec50aa..c16339d7bdb116e20ce13b8ecf3c22fe65543d0a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2004-02-09 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+       * src/SDCCsymt.h,
+       * src/SDCCicode.c (operandFromSymbol),
+       * src/mcs51/ralloc.c (verifyRegsAssigned, serialRegAssign),
+       * src/ds390/ralloc.c (verifyRegsAssigned, serialRegAssign),
+       * src/z80/ralloc.c (verifyRegsAssigned, serialRegAssign),
+       * src/hc08/ralloc.c (verifyRegsAssigned, serialRegAssign),
+       * src/pic/ralloc.c (verifyRegsAssigned, serialRegAssign),
+       * src/pic16/ralloc.c (verifyRegsAssigned, serialRegAssign): fixed
+       bug #892038
+       * src/SDCCast.c (createIvalStruct, createIvalArray, gatherAutoInit),
+       * src/SDCCglue.c (emitRegularMap, printIvalStruct, printIvalArray,
+       printIvalCharPtr, printIvalPtr, printIval, emitStaticSeg, emitOverlay)
+       * src/SDCCsymt.c (newSymbol),
+       * src/SDCC.y (struct_or_union_specifier, enum_specifier, 
+       enumerator_list),
+       * src/SDCCval.h,
+       * src/SDCCval.c (newiList): fixed bug #885705
+
 2004-02-08  Jesus Calvino-Fraga <jesusc AT ece.ubc.ca>
 
        * doc/sdccman.lyx: added section 3.1.4: sdcclib.
index 801fad44522ec8b572b58cbe966109f8611993c6..71f238c05146bd60af185992f28b0a32babd9e49 100644 (file)
@@ -748,17 +748,17 @@ struct_or_union_specifier
           // check for errors in structure members
           for (sym=$5; sym; sym=sym->next) {
             if (IS_ABSOLUTE(sym->etype)) {
-              werrorfl(filename, sym->lineDef, E_NOT_ALLOWED, "'at'");
+              werrorfl(sym->fileDef, sym->lineDef, E_NOT_ALLOWED, "'at'");
               SPEC_ABSA(sym->etype) = 0;
             }
             if (IS_SPEC(sym->etype) && SPEC_SCLS(sym->etype)) {
-              werrorfl(filename, sym->lineDef, E_NOT_ALLOWED, "storage class");
+              werrorfl(sym->fileDef, sym->lineDef, E_NOT_ALLOWED, "storage class");
               printTypeChainRaw (sym->type,NULL);
               SPEC_SCLS(sym->etype) = 0;
             }
             for (dsym=sym->next; dsym; dsym=dsym->next) {
               if (strcmp(sym->name, dsym->name)==0) {
-                werrorfl(filename, sym->lineDef, E_DUPLICATE_MEMBER, 
+                werrorfl(sym->fileDef, sym->lineDef, E_DUPLICATE_MEMBER, 
                        $1==STRUCT ? "struct" : "union", sym->name);
               }
             }
@@ -909,7 +909,7 @@ enum_specifier
 
      csym=findSym(enumTab,$2,$2->name);
      if ((csym && csym->level == $2->level))
-       werrorfl(filename, $2->lineDef, E_DUPLICATE_TYPEDEF,csym->name);
+       werrorfl($2->fileDef, $2->lineDef, E_DUPLICATE_TYPEDEF,csym->name);
      
      enumtype = newEnumType ($4);      //copyLinkChain(cenum->type);
      SPEC_SCLS(getSpec(enumtype)) = 0;
@@ -944,7 +944,7 @@ enumerator_list
        for (dsym=$1; dsym; dsym=dsym->next)
          {
           if (strcmp($3->name, dsym->name)==0)
-            werrorfl(filename, $3->lineDef, E_DUPLICATE_MEMBER, "enum", $3->name);
+            werrorfl($3->fileDef, $3->lineDef, E_DUPLICATE_MEMBER, "enum", $3->name);
         }
        
        $3->next = $1 ;
index 2c9e149043f20f51ac8ae9336d793751d3894299..62efaa6d37eedbaefafaf494df821cadcbd0fd49 100644 (file)
@@ -871,7 +871,7 @@ createIvalStruct (ast * sym, sym_link * type, initList * ilist)
     }
 
   if (iloop) {
-    werrorfl (filename, sym->opval.val->sym->lineDef,
+    werrorfl (sym->opval.val->sym->fileDef, sym->opval.val->sym->lineDef,
              W_EXCESS_INITIALIZERS, "struct", 
              sym->opval.val->sym->name);
   }
@@ -932,6 +932,7 @@ createIvalArray (ast * sym, sym_link * type, initList * ilist)
            // Array size was specified, and we have more initializers than needed.
            char *name=sym->opval.val->sym->name;
            int lineno=sym->opval.val->sym->lineDef;
+           char *filename=sym->opval.val->sym->fileDef;
            
            werrorfl (filename, lineno, W_EXCESS_INITIALIZERS, "array", name);
        }
@@ -958,6 +959,7 @@ createIvalArray (ast * sym, sym_link * type, initList * ilist)
                // there has to be a better way
                char *name=sym->opval.val->sym->name;
                int lineno=sym->opval.val->sym->lineDef;
+               char *filename=sym->opval.val->sym->fileDef;
                werrorfl (filename, lineno, W_EXCESS_INITIALIZERS, "array", name);
                
                break;
@@ -1132,7 +1134,7 @@ gatherAutoInit (symbol * autoChain)
            work = initAggregates (sym, sym->ival, NULL);
          } else {
            if (getNelements(sym->type, sym->ival)>1) {
-             werrorfl (filename, sym->lineDef,
+             werrorfl (sym->fileDef, sym->lineDef,
                        W_EXCESS_INITIALIZERS, "scalar", 
                        sym->name);
            }
@@ -1168,7 +1170,7 @@ gatherAutoInit (symbol * autoChain)
            work = initAggregates (sym, sym->ival, NULL);
          } else {
            if (getNelements(sym->type, sym->ival)>1) {
-             werrorfl (filename, sym->lineDef,
+             werrorfl (sym->fileDef, sym->lineDef,
                        W_EXCESS_INITIALIZERS, "scalar", 
                        sym->name);
            }
index 1a4913767ad331b6a58c8b801cf55487f272b63d..222b11d23a0d758c7dcbe9258d140d77a11f3a2d 100644 (file)
@@ -304,7 +304,7 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag)
            ival = initAggregates (sym, sym->ival, NULL);
          } else {
            if (getNelements(sym->type, sym->ival)>1) {
-             werrorfl (filename, sym->lineDef, W_EXCESS_INITIALIZERS, "scalar", 
+             werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "scalar", 
                      sym->name);
            }
            ival = newNode ('=', newAst_VALUE (symbolVal (sym)),
@@ -351,7 +351,7 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag)
       else {
        int size = getSize (sym->type);
        if (size==0) {
-         werrorfl (filename, sym->lineDef, E_UNKNOWN_SIZE, sym->name);
+         werrorfl (sym->fileDef, sym->lineDef, E_UNKNOWN_SIZE, sym->name);
        }
        /* allocate space */
        if (options.debug) {
@@ -746,7 +746,7 @@ printIvalStruct (symbol * sym, sym_link * type,
 
        sflds = SPEC_STRUCT (type)->fields;
        if (ilist->type != INIT_DEEP) {
-               werrorfl (filename, sym->lineDef, E_INIT_STRUCT, sym->name);
+               werrorfl (sym->fileDef, sym->lineDef, E_INIT_STRUCT, sym->name);
                return;
        }
 
@@ -760,7 +760,7 @@ printIvalStruct (symbol * sym, sym_link * type,
                }
        }
        if (iloop) {
-         werrorfl (filename, sym->lineDef, W_EXCESS_INITIALIZERS, "struct", sym->name);
+         werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "struct", sym->name);
        }
        return;
 }
@@ -810,7 +810,7 @@ printIvalArray (symbol * sym, sym_link * type, initList * ilist,
   /* by a string                      */
   if (IS_CHAR (type->next)) {
     if (!IS_LITERAL(list2val(ilist)->etype)) {
-      werrorfl (filename, ilist->lineno, E_CONST_EXPECTED);
+      werrorfl (ilist->filename, ilist->lineno, E_CONST_EXPECTED);
       return;
     }
     if (printIvalChar (type,
@@ -821,7 +821,7 @@ printIvalArray (symbol * sym, sym_link * type, initList * ilist,
   /* not the special case             */
   if (ilist->type != INIT_DEEP)
     {
-      werrorfl (filename, ilist->lineno, E_INIT_STRUCT, sym->name);
+      werrorfl (ilist->filename, ilist->lineno, E_INIT_STRUCT, sym->name);
       return;
     }
 
@@ -830,7 +830,7 @@ printIvalArray (symbol * sym, sym_link * type, initList * ilist,
       printIval (sym, type->next, iloop, oFile);
       
       if (++size > DCL_ELEM(type)) {
-       werrorfl (filename, sym->lineDef, W_EXCESS_INITIALIZERS, "array", sym->name);
+       werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "array", sym->name);
        break;
       }
     }
@@ -869,7 +869,7 @@ printIvalFuncPtr (sym_link * type, initList * ilist, FILE * oFile)
 
   if (IS_LITERAL(val->etype)) {
     if (compareType(type,val->etype)==0) {
-      werrorfl (filename, ilist->lineno, E_INCOMPAT_TYPES);
+      werrorfl (ilist->filename, ilist->lineno, E_INCOMPAT_TYPES);
       printFromToType (val->type, type);
     }
     printIvalCharPtr (NULL, type, val, oFile);
@@ -980,7 +980,7 @@ printIvalCharPtr (symbol * sym, sym_link * type, value * val, FILE * oFile)
        case 3:
          if (IS_GENPTR(type) && floatFromVal(val)!=0) {
            // non-zero mcs51 generic pointer
-           werrorfl (filename, sym->lineDef, E_LITERAL_GENERIC);
+           werrorfl (sym->fileDef, sym->lineDef, E_LITERAL_GENERIC);
          }
          if (port->little_endian) {
            fprintf (oFile, "\t.byte %s,%s,%s\n",
@@ -997,7 +997,7 @@ printIvalCharPtr (symbol * sym, sym_link * type, value * val, FILE * oFile)
        case 4:
          if (IS_GENPTR(type) && floatFromVal(val)!=0) {
            // non-zero ds390 generic pointer
-           werrorfl (filename, sym->lineDef, E_LITERAL_GENERIC);
+           werrorfl (sym->fileDef, sym->lineDef, E_LITERAL_GENERIC);
          }
          if (port->little_endian) {
            fprintf (oFile, "\t.byte %s,%s,%s,%s\n",
@@ -1055,7 +1055,7 @@ printIvalPtr (symbol * sym, sym_link * type, initList * ilist, FILE * oFile)
 
   /* check the type      */
   if (compareType (type, val->type) == 0) {
-    werrorfl (filename, ilist->lineno, W_INIT_WRONG);
+    werrorfl (ilist->filename, ilist->lineno, W_INIT_WRONG);
     printFromToType (val->type, type);
   }
 
@@ -1143,7 +1143,7 @@ printIval (symbol * sym, sym_link * type, initList * ilist, FILE * oFile)
   if (ilist->type!=INIT_NODE) {
       // or a 1-element list
     if (ilist->init.deep->next) {
-      werrorfl (filename, sym->lineDef, W_EXCESS_INITIALIZERS, "scalar", 
+      werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "scalar", 
              sym->name);
     } else {
       ilist=ilist->init.deep;
@@ -1160,7 +1160,7 @@ printIval (symbol * sym, sym_link * type, initList * ilist, FILE * oFile)
        IS_PTR(type) && DCL_TYPE(type)==CPOINTER) {
       // no sweat
     } else {
-      werrorfl (filename, ilist->lineno, E_TYPE_MISMATCH, "assignment", " ");
+      werrorfl (ilist->filename, ilist->lineno, E_TYPE_MISMATCH, "assignment", " ");
       printFromToType(itype, type);
     }
   }
@@ -1259,7 +1259,7 @@ emitStaticSeg (memmap * map, FILE * out)
              int size = getSize (sym->type);
              
              if (size==0) {
-                 werrorfl (filename, sym->lineDef, E_UNKNOWN_SIZE,sym->name);
+                 werrorfl (sym->fileDef, sym->lineDef, E_UNKNOWN_SIZE,sym->name);
              }
              fprintf (out, "%s:\n", sym->rname);
              /* special case for character strings */
@@ -1515,7 +1515,7 @@ emitOverlay (FILE * afile)
              int size = getSize(sym->type);
 
              if (size==0) {
-                 werrorfl (filename, sym->lineDef, E_UNKNOWN_SIZE);
+                 werrorfl (sym->fileDef, sym->lineDef, E_UNKNOWN_SIZE);
              }       
              if (options.debug)
                  fprintf (afile, "==.\n");
index 34d5437540c6125cef986479e30be5e8d9f84e78..381a2bcb68800c04c9c113714d324b0adfc808ef 100644 (file)
@@ -1533,6 +1533,7 @@ operandFromSymbol (symbol * sym)
          and before liveRange calculation */
       sym->reqv = newiTempOperand (sym->type, 0);
       sym->reqv->key = sym->key;
+      OP_SYMBOL (sym->reqv)->prereqv = sym;
       OP_SYMBOL (sym->reqv)->key = sym->key;
       OP_SYMBOL (sym->reqv)->isreqv = 1;
       OP_SYMBOL (sym->reqv)->islocal = 1;
index d3bfee79b661bfee51ab05509da4d5798c60753d..88df7febb8e96c0f8cf30fda4f6c22e19535a661 100644 (file)
@@ -293,6 +293,7 @@ newSymbol (char *name, int scope)
   sym->level = scope;          /* set the level    */
   sym->block = currBlockno;
   sym->lineDef = mylineno;     /* set the line number */
+  sym->fileDef = currFname;
   return sym;
 }
 
index 9a4860b82487dbab851e281cc4820713242dadb4..0ac55f77d55de518cfaf45e74a3fd2c718c35bc4 100644 (file)
@@ -297,6 +297,7 @@ typedef struct symbol
     struct iCode *fuse;                /* furthest use */
     struct iCode *rematiCode;  /* rematerialse with which instruction */
     struct operand *reqv;      /* register equivalent of a local variable */
+    struct symbol *prereqv;    /* symbol before register equiv. substituion */
     union
       {
        struct symbol *spillLoc;        /* register spil location */
@@ -307,6 +308,7 @@ typedef struct symbol
     unsigned offset;           /* offset from top if struct */
 
     int lineDef;               /* defined line number        */
+    char *fileDef;             /* defined filename           */
     int lastLine;              /* for functions the last line */
     struct sym_link *type;     /* 1st link to declator chain */
     struct sym_link *etype;    /* last link to declarator chn */
index a0d5e15c31b90aebdb88f2112aaf271fa3f8812e..e72baee3c2e524f43b7148ad63eaf424f5901978 100644 (file)
@@ -57,6 +57,7 @@ newiList (int type, void *ilist)
 
   nilist->type = type;
   nilist->lineno = mylineno;
+  nilist->filename = currFname;
 
   switch (type)
     {
index 92e622fbb4972d45629129e034b214d640f3d936..d49495a85157e5a5e050fb578b39dcc99d4b77f0 100644 (file)
@@ -57,6 +57,7 @@ typedef struct initList
   {
     int type;
     int lineno;
+    char *filename;
     union
       {
        struct ast *node;
index 42de2a96aeabbd444d148714f40bd42ae4d87eb3..8760bd7b50b06629ff0f87189ccdcdc9ec75594a 100644 (file)
@@ -1210,6 +1210,31 @@ void reassignUnusedLRs (bitVect *unused)
     }
 }
 
+/*------------------------------------------------------------------*/
+/* verifyRegsAssigned - make sure an iTemp is properly initialized; */
+/* it should either have registers or have beed spilled. Otherwise, */
+/* there was an uninitialized variable, so just spill this to get   */
+/* the operand in a valid state.                                    */
+/*------------------------------------------------------------------*/
+static void
+verifyRegsAssigned (operand *op, iCode * ic)
+{
+  symbol * sym;
+  
+  if (!op) return;
+  if (!IS_ITEMP (op)) return;
+  
+  sym = OP_SYMBOL (op);
+  if (sym->isspilt) return;
+  if (!sym->nRegs) return;
+  if (sym->regs[0]) return;
+  
+  werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT, 
+           sym->prereqv ? sym->prereqv->name : sym->name);
+  spillThis (sym);
+}
+
+
 /*-----------------------------------------------------------------*/
 /* serialRegAssign - serially allocate registers to the variables  */
 /*-----------------------------------------------------------------*/
@@ -1379,6 +1404,40 @@ serialRegAssign (eBBlock ** ebbs, int count)
        }
       reassignUnusedLRs(unusedLRs);
     }
+
+    /* Check for and fix any problems with uninitialized operands */
+    for (i = 0; i < count; i++)
+      {
+       iCode *ic;
+
+       if (ebbs[i]->noPath &&
+           (ebbs[i]->entryLabel != entryLabel &&
+            ebbs[i]->entryLabel != returnLabel))
+           continue;
+
+       for (ic = ebbs[i]->sch; ic; ic = ic->next)
+         {
+           if (SKIP_IC2 (ic))
+             continue;
+
+           if (ic->op == IFX)
+             {
+               verifyRegsAssigned (IC_COND (ic), ic);
+               continue;
+             }
+
+           if (ic->op == JUMPTABLE)
+             {
+               verifyRegsAssigned (IC_JTCOND (ic), ic);
+               continue;
+             }
+
+           verifyRegsAssigned (IC_RESULT (ic), ic);
+           verifyRegsAssigned (IC_LEFT (ic), ic);
+           verifyRegsAssigned (IC_RIGHT (ic), ic);
+          }
+      }    
+    
 }
 
 /*-----------------------------------------------------------------*/
index be4a1c977ebce08c6d594969155ca09f01e06c4b..ee599f19353b95df7c0a021a1dfa297b7062ab6e 100644 (file)
@@ -1169,6 +1169,32 @@ xchgPositions:
   return change;
 }
 
+/*------------------------------------------------------------------*/
+/* verifyRegsAssigned - make sure an iTemp is properly initialized; */
+/* it should either have registers or have beed spilled. Otherwise, */
+/* there was an uninitialized variable, so just spill this to get   */
+/* the operand in a valid state.                                    */
+/*------------------------------------------------------------------*/
+static void
+verifyRegsAssigned (operand *op, iCode * ic)
+{
+  symbol * sym;
+  
+  if (!op) return;
+  if (!IS_ITEMP (op)) return;
+  
+  sym = OP_SYMBOL (op);
+  if (sym->isspilt) return;
+  if (!sym->nRegs) return;
+  if (sym->regs[0]) return;
+  
+  werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT, 
+           sym->prereqv ? sym->prereqv->name : sym->name);
+  spillThis (sym);
+}
+
+
+
 /*-----------------------------------------------------------------*/
 /* serialRegAssign - serially allocate registers to the variables  */
 /*-----------------------------------------------------------------*/
@@ -1329,6 +1355,40 @@ serialRegAssign (eBBlock ** ebbs, int count)
            }
        }
     }
+
+    /* Check for and fix any problems with uninitialized operands */
+    for (i = 0; i < count; i++)
+      {
+       iCode *ic;
+
+       if (ebbs[i]->noPath &&
+           (ebbs[i]->entryLabel != entryLabel &&
+            ebbs[i]->entryLabel != returnLabel))
+           continue;
+
+       for (ic = ebbs[i]->sch; ic; ic = ic->next)
+         {
+           if (SKIP_IC2 (ic))
+             continue;
+
+           if (ic->op == IFX)
+             {
+               verifyRegsAssigned (IC_COND (ic), ic);
+               continue;
+             }
+
+           if (ic->op == JUMPTABLE)
+             {
+               verifyRegsAssigned (IC_JTCOND (ic), ic);
+               continue;
+             }
+
+           verifyRegsAssigned (IC_RESULT (ic), ic);
+           verifyRegsAssigned (IC_LEFT (ic), ic);
+           verifyRegsAssigned (IC_RIGHT (ic), ic);
+          }
+      }    
+
 }
 
 /*-----------------------------------------------------------------*/
index e45b233caf762198fd5dfc85d2c44fcf9985a920..a8273950f562f4dfcd33482d0421589523601acf 100644 (file)
@@ -1099,6 +1099,33 @@ xchgPositions:
   return change;
 }
 
+
+/*------------------------------------------------------------------*/
+/* verifyRegsAssigned - make sure an iTemp is properly initialized; */
+/* it should either have registers or have beed spilled. Otherwise, */
+/* there was an uninitialized variable, so just spill this to get   */
+/* the operand in a valid state.                                    */
+/*------------------------------------------------------------------*/
+static void
+verifyRegsAssigned (operand *op, iCode * ic)
+{
+  symbol * sym;
+  
+  if (!op) return;
+  if (!IS_ITEMP (op)) return;
+  
+  sym = OP_SYMBOL (op);
+  if (sym->isspilt) return;
+  if (!sym->nRegs) return;
+  if (sym->regs[0]) return;
+  
+  werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT, 
+           sym->prereqv ? sym->prereqv->name : sym->name);
+  spillThis (sym);
+}
+
+
+
 /*-----------------------------------------------------------------*/
 /* serialRegAssign - serially allocate registers to the variables  */
 /*-----------------------------------------------------------------*/
@@ -1272,6 +1299,39 @@ serialRegAssign (eBBlock ** ebbs, int count)
            }
        }
     }
+
+    /* Check for and fix any problems with uninitialized operands */
+    for (i = 0; i < count; i++)
+      {
+       iCode *ic;
+
+       if (ebbs[i]->noPath &&
+           (ebbs[i]->entryLabel != entryLabel &&
+            ebbs[i]->entryLabel != returnLabel))
+           continue;
+
+       for (ic = ebbs[i]->sch; ic; ic = ic->next)
+         {
+           if (SKIP_IC2 (ic))
+             continue;
+
+           if (ic->op == IFX)
+             {
+               verifyRegsAssigned (IC_COND (ic), ic);
+               continue;
+             }
+
+           if (ic->op == JUMPTABLE)
+             {
+               verifyRegsAssigned (IC_JTCOND (ic), ic);
+               continue;
+             }
+
+           verifyRegsAssigned (IC_RESULT (ic), ic);
+           verifyRegsAssigned (IC_LEFT (ic), ic);
+           verifyRegsAssigned (IC_RIGHT (ic), ic);
+          }
+      }    
 }
 
 /*-----------------------------------------------------------------*/
@@ -1445,6 +1505,7 @@ mcs51_rUmaskForOp (operand * op)
 
   for (j = 0; j < sym->nRegs; j++)
     {
+      if (sym->regs[j]) /* EEP - debug */
       rumask = bitVectSetBit (rumask,
                              sym->regs[j]->rIdx);
     }
index 6c67f75c8de2ff5c59f3d0faff04650ca040952f..7266470d807428f67e2970f7407a1c7e76b6dd71 100644 (file)
@@ -2204,6 +2204,31 @@ xchgPositions:
        }
 }
 
+/*------------------------------------------------------------------*/
+/* verifyRegsAssigned - make sure an iTemp is properly initialized; */
+/* it should either have registers or have beed spilled. Otherwise, */
+/* there was an uninitialized variable, so just spill this to get   */
+/* the operand in a valid state.                                    */
+/*------------------------------------------------------------------*/
+static void
+verifyRegsAssigned (operand *op, iCode * ic)
+{
+  symbol * sym;
+  
+  if (!op) return;
+  if (!IS_ITEMP (op)) return;
+  
+  sym = OP_SYMBOL (op);
+  if (sym->isspilt) return;
+  if (!sym->nRegs) return;
+  if (sym->regs[0]) return;
+  
+  werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT, 
+           sym->prereqv ? sym->prereqv->name : sym->name);
+  spillThis (sym);
+}
+
+
 /*-----------------------------------------------------------------*/
 /* serialRegAssign - serially allocate registers to the variables  */
 /*-----------------------------------------------------------------*/
@@ -2372,6 +2397,40 @@ serialRegAssign (eBBlock ** ebbs, int count)
                }
        }
        }
+
+    /* Check for and fix any problems with uninitialized operands */
+    for (i = 0; i < count; i++)
+      {
+       iCode *ic;
+
+       if (ebbs[i]->noPath &&
+           (ebbs[i]->entryLabel != entryLabel &&
+            ebbs[i]->entryLabel != returnLabel))
+           continue;
+
+       for (ic = ebbs[i]->sch; ic; ic = ic->next)
+         {
+           if (SKIP_IC2 (ic))
+             continue;
+
+           if (ic->op == IFX)
+             {
+               verifyRegsAssigned (IC_COND (ic), ic);
+               continue;
+             }
+
+           if (ic->op == JUMPTABLE)
+             {
+               verifyRegsAssigned (IC_JTCOND (ic), ic);
+               continue;
+             }
+
+           verifyRegsAssigned (IC_RESULT (ic), ic);
+           verifyRegsAssigned (IC_LEFT (ic), ic);
+           verifyRegsAssigned (IC_RIGHT (ic), ic);
+          }
+      }    
+
 }
 
 /*-----------------------------------------------------------------*/
index 2f21d2215cb5b88ebda785d52ca8b6557e1f7a5f..58b8906b91164bd655c32f76c228b3381a069d95 100644 (file)
@@ -2013,6 +2013,31 @@ xchgPositions:
     }
 }
 
+/*------------------------------------------------------------------*/
+/* verifyRegsAssigned - make sure an iTemp is properly initialized; */
+/* it should either have registers or have beed spilled. Otherwise, */
+/* there was an uninitialized variable, so just spill this to get   */
+/* the operand in a valid state.                                    */
+/*------------------------------------------------------------------*/
+static void
+verifyRegsAssigned (operand *op, iCode * ic)
+{
+  symbol * sym;
+  
+  if (!op) return;
+  if (!IS_ITEMP (op)) return;
+  
+  sym = OP_SYMBOL (op);
+  if (sym->isspilt) return;
+  if (!sym->nRegs) return;
+  if (sym->regs[0]) return;
+  
+  werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT, 
+           sym->prereqv ? sym->prereqv->name : sym->name);
+  spillThis (sym);
+}
+
+
 /*-----------------------------------------------------------------*/
 /* serialRegAssign - serially allocate registers to the variables  */
 /*-----------------------------------------------------------------*/
@@ -2182,6 +2207,40 @@ serialRegAssign (eBBlock ** ebbs, int count)
            }
        }
     }
+
+    /* Check for and fix any problems with uninitialized operands */
+    for (i = 0; i < count; i++)
+      {
+       iCode *ic;
+
+       if (ebbs[i]->noPath &&
+           (ebbs[i]->entryLabel != entryLabel &&
+            ebbs[i]->entryLabel != returnLabel))
+           continue;
+
+       for (ic = ebbs[i]->sch; ic; ic = ic->next)
+         {
+           if (SKIP_IC2 (ic))
+             continue;
+
+           if (ic->op == IFX)
+             {
+               verifyRegsAssigned (IC_COND (ic), ic);
+               continue;
+             }
+
+           if (ic->op == JUMPTABLE)
+             {
+               verifyRegsAssigned (IC_JTCOND (ic), ic);
+               continue;
+             }
+
+           verifyRegsAssigned (IC_RESULT (ic), ic);
+           verifyRegsAssigned (IC_LEFT (ic), ic);
+           verifyRegsAssigned (IC_RIGHT (ic), ic);
+          }
+      }    
+    
 }
 
 /*-----------------------------------------------------------------*/
index 17d3b8065db114c3af2d14143ab5272c768d18af..ed6868c8d7326ca591ba8ba61b9eb571a75875c4 100644 (file)
@@ -1046,6 +1046,31 @@ tryAllocatingRegPair (symbol * sym)
   return FALSE;
 }
 
+/*------------------------------------------------------------------*/
+/* verifyRegsAssigned - make sure an iTemp is properly initialized; */
+/* it should either have registers or have beed spilled. Otherwise, */
+/* there was an uninitialized variable, so just spill this to get   */
+/* the operand in a valid state.                                    */
+/*------------------------------------------------------------------*/
+static void
+verifyRegsAssigned (operand *op, iCode * ic)
+{
+  symbol * sym;
+  
+  if (!op) return;
+  if (!IS_ITEMP (op)) return;
+  
+  sym = OP_SYMBOL (op);
+  if (sym->isspilt) return;
+  if (!sym->nRegs) return;
+  if (sym->regs[0]) return;
+  
+  werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT, 
+           sym->prereqv ? sym->prereqv->name : sym->name);
+  spillThis (sym);
+}
+
+
 /** Serially allocate registers to the variables.
     This is the main register allocation function.  It is called after
     packing.
@@ -1206,6 +1231,40 @@ serialRegAssign (eBBlock ** ebbs, int count)
            }
        }
     }
+
+    /* Check for and fix any problems with uninitialized operands */
+    for (i = 0; i < count; i++)
+      {
+       iCode *ic;
+
+       if (ebbs[i]->noPath &&
+           (ebbs[i]->entryLabel != entryLabel &&
+            ebbs[i]->entryLabel != returnLabel))
+           continue;
+
+       for (ic = ebbs[i]->sch; ic; ic = ic->next)
+         {
+           if (SKIP_IC2 (ic))
+             continue;
+
+           if (ic->op == IFX)
+             {
+               verifyRegsAssigned (IC_COND (ic), ic);
+               continue;
+             }
+
+           if (ic->op == JUMPTABLE)
+             {
+               verifyRegsAssigned (IC_JTCOND (ic), ic);
+               continue;
+             }
+
+           verifyRegsAssigned (IC_RESULT (ic), ic);
+           verifyRegsAssigned (IC_LEFT (ic), ic);
+           verifyRegsAssigned (IC_RIGHT (ic), ic);
+          }
+      }    
+
 }
 
 /*-----------------------------------------------------------------*/