]> andersk Git - splint.git/blobdiff - src/uentry.c
Fixed overly agressive assertions (from checking splint *.c in test/)
[splint.git] / src / uentry.c
index 1deb565f4e478725d1e47f1f12c208c2a257b798..831bcbf64aef3b13ce3e1d3ce93f42c12094fd76 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ** Splint - annotation-assisted static program checker
-** Copyright (C) 1994-2002 University of Virginia,
+** Copyright (C) 1994-2003 University of Virginia,
 **         Massachusetts Institute of Technology
 **
 ** This program is free software; you can redistribute it and/or modify it
@@ -17,8 +17,8 @@
 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 ** MA 02111-1307, USA.
 **
-** For information on splint: splint@cs.virginia.edu
-** To report a bug: splint-bug@cs.virginia.edu
+** For information on splint: info@splint.org
+** To report a bug: splint-bug@splint.org
 ** For more information: http://www.splint.org
 */
 /*
@@ -43,7 +43,7 @@ static bool uentry_isReallySpecified (uentry p_e) /*@*/ ;
 static void uentry_checkIterArgs (uentry p_ue);
 static cstring uentry_dumpAux (uentry p_v, bool p_isParam);
 
-static void uentry_showWhereLastKind (uentry p_spec) /*@modifies g_msgstream@*/ ; 
+static void uentry_showWhereLastKind (uentry p_spec) /*@modifies g_warningstream@*/ ; 
 
 static void uentry_combineModifies (uentry p_ue, /*@owned@*/ sRefSet p_sr) 
      /*@modifies p_ue@*/ ;
@@ -66,10 +66,8 @@ static void checkVarConformance (/*@notnull@*/ uentry p_old,
                                 bool p_mustConform, bool p_completeConform) 
    /*@modifies p_old, p_unew@*/;
 
-# ifndef NOLCL
 static void uentry_setHasMods (uentry p_ue) /*@modifies p_ue@*/;
 static void uentry_setHasGlobs (uentry p_ue) /*@modifies p_ue@*/;
-# endif
 
 static void uentry_reallyFree (/*@notnull@*/ /*@only@*/ uentry p_e);
 
@@ -86,7 +84,7 @@ static void
   paramTypeError (/*@notnull@*/ uentry p_old, /*@notnull@*/ uentry p_oldCurrent,
                  ctype p_oldType, /*@notnull@*/ uentry p_unew,
                  /*@notnull@*/ uentry p_newCurrent, 
-                 ctype p_newType, int p_paramno) /*@modifies g_msgstream@*/ ;
+                 ctype p_newType, int p_paramno) /*@modifies g_warningstream@*/ ;
 
 static /*@only@*/ /*@notnull@*/ uentry 
   uentry_makeVariableAux (cstring p_n, ctype p_t, /*@keep@*/ fileloc p_f,
@@ -110,7 +108,7 @@ static void uentry_convertVarFunction (uentry ue) /*@modifies ue@*/
 static /*@out@*/ /*@notnull@*/ uentry uentry_alloc (void) /*@*/ 
 {
   uentry ue = (uentry) dmalloc (sizeof (*ue));
-  ue->warn = warnClause_undefined; /*@i32@*/
+  ue->warn = warnClause_undefined; 
   nuentries++;
   totuentries++;
   
@@ -687,7 +685,6 @@ static void uentry_setConstantValue (uentry ue, /*@only@*/ multiVal val)
   return ue;
 }
 
-# ifndef NOLCL
 /*@notnull@*/ uentry uentry_makeSpecEnumConstant (cstring n, ctype t, fileloc loc)
 {
   uentry ue = uentry_makeConstant (n, t, loc);
@@ -695,29 +692,32 @@ static void uentry_setConstantValue (uentry ue, /*@only@*/ multiVal val)
   ue->ukind = KENUMCONST;
   return ue;
 }
-# endif
 
 /*@notnull@*/ uentry uentry_makeVariableLoc (cstring n, ctype t)
 {
   return uentry_makeVariable (n, t, setLocation (), FALSE);
 }
 
-# ifndef NOLCL
+bool uentry_isUnnamedVariable (uentry ue)
+{
+  return uentry_isVariable (ue) && cstring_isUndefined (ue->uname);
+}
+
 /*@notnull@*/ /*@only@*/ uentry uentry_makeUnnamedVariable (ctype t)
 {
   return uentry_makeVariable (cstring_undefined, t, setLocation (), FALSE);
 }
-# endif
 
 /*@notnull@*/ uentry uentry_makeIdDatatype (idDecl id)
 {
   ctype ct = idDecl_getCtype (id);
   uentry ue = uentry_makeDatatype (idDecl_observeId (id), ct, 
-                                  MAYBE, MAYBE, setLocation ());
+                                  MAYBE, qual_createUnknown (),
+                                  setLocation ());
 
   uentry_reflectQualifiers (ue, idDecl_getQuals (id));
   
-  if (!ynm_isOn (ue->info->datatype->abs))
+  if (!qual_isEitherAbstract (ue->info->datatype->abs))
     {
       if (ctype_isUnknown (ct))
        {
@@ -741,9 +741,12 @@ void uentry_checkParams (uentry ue)
       if (uentry_isRealFunction (ue))
        {
          uentryList params = uentry_getParams (ue);
+         int paramno = 0;
 
          uentryList_elements (params, current)
            {
+             paramno++;
+
              if (uentry_isValid (current))
                {
                  ctype ct = current->utype;                  
@@ -757,24 +760,48 @@ void uentry_checkParams (uentry ue)
                        }
                      else
                        {
-                         voptgenerror 
-                           (FLG_FIXEDFORMALARRAY,
-                            message ("Function parameter %q declared as "
-                                     "manifest array (size constant is meaningless)",
-                                     uentry_getName (current)),
-                            uentry_whereDeclared (current));
+                         if (uentry_hasName (current))
+                           {
+                             voptgenerror 
+                               (FLG_FIXEDFORMALARRAY,
+                                message ("Function parameter %q declared as "
+                                         "manifest array (size constant is meaningless)",
+                                         uentry_getName (current)),
+                                uentry_whereDeclared (current));
+                           }
+                         else
+                           {
+                             voptgenerror 
+                               (FLG_FIXEDFORMALARRAY,
+                                message ("Unnamed function parameter %d declared as "
+                                         "manifest array (size constant is meaningless)",
+                                         paramno),
+                                uentry_whereDeclared (current));
+                           }
                        }
                    }
                  else 
                    {
                      if (ctype_isArray (ct))
                        {
-                         voptgenerror 
-                           (FLG_FORMALARRAY,
-                            message ("Function parameter %q declared as "
-                                     "array (treated as pointer)", 
-                                     uentry_getName (current)),
-                            uentry_whereDeclared (current));
+                         if (uentry_hasName (current))
+                           {
+                             voptgenerror 
+                               (FLG_FORMALARRAY,
+                                message ("Function parameter %q declared as "
+                                         "array (treated as pointer)", 
+                                         uentry_getName (current)),
+                                uentry_whereDeclared (current));
+                           }
+                         else
+                           {
+                             voptgenerror 
+                               (FLG_FORMALARRAY,
+                                message ("Unnamed function parameter %d declared as "
+                                         "array (treated as pointer)", 
+                                         paramno),
+                                uentry_whereDeclared (current));
+                           }
                        }
                    }
 
@@ -868,7 +895,8 @@ static void reflectImplicitFunctionQualifiers (/*@notnull@*/ uentry ue, bool spe
                        }
                      else 
                        {
-                         if (ctype_isImmutableAbstract (ctype_getReturnType (ue->utype))) 
+                         if (ctype_isImmutableAbstract (ctype_getReturnType (ue->utype))
+                             || ctype_isNumAbstract (ctype_getReturnType (ue->utype)))
                            {
                              ; /* Immutable objects are not shared. */
                            }
@@ -899,9 +927,7 @@ uentry_makeFunctionAux (cstring n, ctype t,
   uentry e = uentry_alloc ();
   ctype ret;
 
-  llassert (warnClause_isUndefined (warn)); /*@i325 remove parameter! */
-
-  DPRINTF (("Make function: %s", n));
+  llassert (warnClause_isUndefined (warn)); 
 
   if (ctype_isFunction (t))
     {
@@ -1031,14 +1057,18 @@ static void uentry_reflectClauses (uentry ue, functionClauseList clauses)
 
          if (uentry_hasGlobs (ue))
            {
-             voptgenerror 
+             vgenhinterror 
                (FLG_SYNTAX,
                 message
                 ("Multiple globals clauses for %q: %q",
                  uentry_getName (ue),
                  globalsClause_unparse (glc)),
+                cstring_makeLiteral ("Only one globals clause may be used. The second globals clause is ignored."),
                 globalsClause_getLoc (glc));
-             uentry_setGlobals (ue, globalsClause_takeGlobs (glc)); /*@i32@*/
+
+             /*                
+               uentry_setGlobals (ue, globalsClause_takeGlobs (glc)); 
+             */
            }
          else
            {
@@ -1073,7 +1103,7 @@ static void uentry_reflectClauses (uentry ue, functionClauseList clauses)
              **
              */
 
-             uentry_combineModifies (ue, modifiesClause_takeMods (mlc)); /*@i32@*/
+             uentry_combineModifies (ue, modifiesClause_takeMods (mlc)); 
            }
          else
            {
@@ -1282,7 +1312,7 @@ static void uentry_implicitParamAnnots (/*@notnull@*/ uentry e)
 
 static /*@only@*/ /*@notnull@*/ uentry 
 uentry_makeVariableParamAux (cstring n, ctype t, /*@dependent@*/ sRef s, 
-                            /*@only@*/ fileloc loc, sstate defstate) /*@i32 exposed*/
+                            /*@only@*/ fileloc loc, sstate defstate)
 {
   cstring pname = makeParam (n);
   uentry e;
@@ -1306,7 +1336,6 @@ uentry_makeVariableParamAux (cstring n, ctype t, /*@dependent@*/ sRef s,
   return (e);
 }
 
-# ifndef NOLCL
 void
 uentry_setRefCounted (uentry e)
 {
@@ -1316,7 +1345,6 @@ uentry_setRefCounted (uentry e)
       sRef_storeState (e->sref);
     }
 }
-# endif
 
 void
 uentry_setStatic (uentry c)
@@ -1445,17 +1473,17 @@ uentry_fixupSref (uentry ue)
   
   if (uentry_isVariable (ue))
     {
-      /*@i634    ue->sref = sRef_saveCopyShallow (ue->info->var->origsref); */
+      /* removed this: no need to copy? ue->sref = sRef_saveCopyShallow (ue->info->var->origsref); */
       sRef_setDefState (sr, ue->info->var->defstate, fileloc_undefined);
       sRef_setNullState (sr, ue->info->var->nullstate, fileloc_undefined);
     }
 }
 
-static void uentry_addStateClause (uentry ue, stateClause sc)
+static void uentry_addStateClause (/*@notnull@*/ uentry ue, stateClause sc)
 {
   /*
   ** Okay to allow multiple clauses of the same kind.
-  */ /*@i834 is this true?@*/
+  */ 
 
   ue->info->fcn->specclauses = 
     stateClauseList_add (ue->info->fcn->specclauses, sc);
@@ -1596,6 +1624,7 @@ bool uentry_hasWarning (uentry ue)
 
 void uentry_addWarning (uentry ue, /*@only@*/ warnClause warn)
 {
+  llassert (uentry_isValid (ue));
   llassert (warnClause_isUndefined (ue->warn));
   ue->warn = warn;
 }
@@ -1620,6 +1649,7 @@ uentry_setPreconditions (uentry ue, /*@only@*/ functionConstraint preconditions)
       
       if (functionConstraint_isDefined (ue->info->fcn->preconditions))
        {
+         /*drl oops this date is wronge...*/
          /* drl 11-29-2002
             I changed this so it didn't appear as a Splint bug
             among other things this gets triggered when there is
@@ -2315,6 +2345,7 @@ uentry_reflectOtherQualifier (/*@notnull@*/ uentry ue, qual qel)
       uentry_setNullState (ue, NS_MNOTNULL);
     }
   else if (qual_isAbstract (qel)
+          || qual_isNumAbstract (qel)
           || qual_isConcrete (qel))
     {
       if (!uentry_isDatatype (ue))
@@ -2327,7 +2358,9 @@ uentry_reflectOtherQualifier (/*@notnull@*/ uentry ue, qual qel)
        }
       else
        {
-         ue->info->datatype->abs = ynm_fromBool (qual_isAbstract (qel));
+         ue->info->datatype->abs = qel;
+         DPRINTF (("Setting abstract %s: %s",
+                   uentry_unparse (ue), qual_unparse (qel)));
        }
     }
   else if (qual_isMutable (qel))
@@ -2466,7 +2499,7 @@ uentry_reflectOtherQualifier (/*@notnull@*/ uentry ue, qual qel)
                        uentry_unparse (ue)),
               uentry_whereLast (ue)))
            {
-             /*@i! annotationInfo_showContextError (ainfo, ue); */
+             /* annotationInfo_showContextError (ainfo, ue); */
            }
        }
     }
@@ -2500,6 +2533,7 @@ uentry_reflectQualifiers (uentry ue, qualList q)
       else if (qual_isUnused (qel))
        {
          uentry_setUsed (ue, fileloc_undefined);         
+         DPRINTF (("Used: %s", uentry_unparseFull (ue)));
        }
       else if (qual_isExternal (qel))
        {
@@ -3036,7 +3070,7 @@ uentry_isSpecialFunction (uentry ue)
   ctype ct = idDecl_getCtype (t);
   ctype base = ct;
   fileloc loc = setLocation ();
-  sRef pref = sRef_makeParam (i, ct, stateInfo_makeLoc (loc));
+  sRef pref = sRef_makeParam (i, ct, stateInfo_makeLoc (loc, SA_CREATED));
   uentry ue = uentry_makeVariableSrefParam (idDecl_observeId (t), ct, loc, pref);
 
   DPRINTF (("Make param: %s", uentry_unparseFull (ue)));
@@ -3085,7 +3119,7 @@ uentry_isSpecialFunction (uentry ue)
     {
       fileloc loc = setLocation ();
       uentry ue = uentry_makeVariable (idDecl_observeId (t), ct, loc, FALSE);
-      
+
       uentry_reflectQualifiers (ue, idDecl_getQuals (t));
 
       if (!uentry_isExtern (ue))
@@ -3097,12 +3131,10 @@ uentry_isSpecialFunction (uentry ue)
     }
 }
 
-# ifndef NOLCL
 /*@notnull@*/ uentry uentry_makeVariableParam (cstring n, ctype t, fileloc loc)
 {
   return (uentry_makeVariableParamAux (n, t, sRef_makeType (t), fileloc_copy (loc), SS_DEFINED));
 }
-# endif
 
 /*
 ** constants
@@ -3120,7 +3152,7 @@ uentry uentry_makeConstantAux (cstring n, ctype t,
   e->utype = t;
   e->storageclass = SCNONE;
 
-  e->warn = warnClause_undefined; /*@i32 warnings for constants? */
+  e->warn = warnClause_undefined; /* Don't support warnings for constants */
 
   e->sref  = sRef_makeConst (t);
 
@@ -3150,17 +3182,20 @@ uentry uentry_makeConstantAux (cstring n, ctype t,
 
 /*@notnull@*/ uentry uentry_makeConstant (cstring n, ctype t, fileloc f)
 {
-  return (uentry_makeConstantAux (n, t, f, FALSE, FALSE, multiVal_unknown ()));
+  uentry ue = uentry_makeConstantAux (n, t, f, FALSE, FALSE, multiVal_unknown ());
+  return ue;
 }
 
 /*@notnull@*/ uentry uentry_makeConstantValue (cstring n, ctype t, fileloc f, bool priv, multiVal val)
 {
-  return (uentry_makeConstantAux (n, t, f, priv, FALSE, val));
+  uentry ue = uentry_makeConstantAux (n, t, f, priv, FALSE, val);
+  return ue;
 }
 
 /*@notnull@*/ uentry uentry_makeMacroConstant (cstring n, ctype t, fileloc f)
 {
-  return (uentry_makeConstantAux (n, t, f, FALSE, TRUE, multiVal_unknown ()));
+  uentry ue = uentry_makeConstantAux (n, t, f, FALSE, TRUE, multiVal_unknown ());
+  return ue;
 }
 
 /*@notnull@*/ uentry uentry_makeIdConstant (idDecl t)
@@ -3262,14 +3297,14 @@ void uentry_setCheckedStrict (uentry ue)
 }
 
 static /*@only@*/ /*@notnull@*/ 
-  uentry uentry_makeVariableAux (cstring n, ctype t, 
-                                fileloc f,
-                                /*@exposed@*/ sRef s,
-                                bool priv, vkind kind)
+uentry uentry_makeVariableAux (cstring n, ctype t, 
+                              fileloc f,
+                              /*@exposed@*/ sRef s,
+                              bool priv, vkind kind)
 {
   uentry e = uentry_alloc ();
   ctype rt = t;
-
+  
   DPRINTF (("Make variable: %s %s %s", n, ctype_unparse (t), sRef_unparse (s)));
 
   e->ukind = KVAR;
@@ -3278,7 +3313,7 @@ static /*@only@*/ /*@notnull@*/
 
   e->storageclass = SCNONE;
 
-  e->warn = warnClause_undefined; /*@i32 warnings for variable @*/
+  e->warn = warnClause_undefined; /* Don't support warnings for variables yet @*/
 
   e->sref  = s;
 
@@ -3293,7 +3328,7 @@ static /*@only@*/ /*@notnull@*/
   e->info->var = (uvinfo) dmalloc (sizeof (*e->info->var));
   e->info->var->kind = kind;
 
-  /*@i523 e->info->var->origsref = sRef_saveCopy (e->sref); */
+  /* removed: e->info->var->origsref = sRef_saveCopy (e->sref); */
   e->info->var->checked = CH_UNKNOWN;
 
   DPRINTF (("Here we are: %s", sRef_unparseFull (e->sref)));
@@ -3320,19 +3355,17 @@ static /*@only@*/ /*@notnull@*/
      it allocates memory and sets the fields. We check if the type of the variable
      is a pointer or array and allocate a `bbufinfo' struct accordingly */
   
-  if( ctype_isArray (t) || ctype_isPointer(t)) {
-    /*@i222@*/e->info->var->bufinfo = dmalloc( sizeof(*e->info->var->bufinfo) );
-     e->info->var->bufinfo->bufstate = BB_NOTNULLTERMINATED;
-     /*@access sRef@*/ /*i@222*/
-     /* It probably isn't necessary to violate the abstraction here
-      I'll fix this later
-     */
-     s->bufinfo.bufstate = BB_NOTNULLTERMINATED;
-     /*@noaccess sRef@*/
-  } else {
-     e->info->var->bufinfo = NULL;
-  }/* end else */
-/* end modification */
+  if (ctype_isArray (t) || ctype_isPointer(t))
+    {
+      e->info->var->bufinfo = dmalloc (sizeof (*e->info->var->bufinfo));
+      e->info->var->bufinfo->bufstate = BB_NOTNULLTERMINATED;
+      sRef_setNotNullTerminatedState (s);
+    } 
+  else 
+    {
+      e->info->var->bufinfo = NULL;
+    }/* end else */
+  /* end modification */
 
   return (e);
 }
@@ -3585,36 +3618,24 @@ void uentry_makeConstantFunction (uentry ue)
 }
 
 void
-uentry_setGlobals (uentry ue, /*@owned@*/ globSet globs)
+uentry_setGlobals (uentry ue, /*@only@*/ globSet globs)
 {
   llassert (uentry_isValid (ue));
 
+  globSet_markImmutable (globs);
+
   if (uentry_isIter (ue))
     {
-      llassert (globSet_isUndefined (ue->info->iter->globs));
-      ue->info->iter->globs = globs;
+      ue->info->iter->globs = globSet_unionFree (ue->info->iter->globs, globs);
     }
   else
     {
       uentry_convertVarFunction (ue);
-      
       llassert (uentry_isFunction (ue));
-      llassert (!ue->info->fcn->hasGlobs 
-               && globSet_isUndefined (ue->info->fcn->globs));
-      
-      ue->info->fcn->hasGlobs = TRUE;
-      globSet_markImmutable (globs);
-      /*@-mustfree@*/ ue->info->fcn->globs = globs;
-      /*@=mustfree@*/
-    }
 
-  /*@i23*/
-  /* ???  - evans 2001-09-09 not sure what's going on here...?
-  if (globSet_hasStatic (globs))
-    {
-      context_recordFileGlobals (globs);
+      ue->info->fcn->hasGlobs = TRUE;
+      ue->info->fcn->globs = globSet_unionFree (ue->info->fcn->globs, globs);
     }
-  */
 
   if (context_getFlag (FLG_GLOBALSIMPMODIFIESNOTHING))
     {
@@ -3653,7 +3674,7 @@ void uentry_addAccessType (uentry ue, typeId tid)
                       /*@only@*/ warnClause warn,
                       fileloc f)
 {
-  llassert (warnClause_isUndefined (warn)); /*@i325 remove parameter! */
+  llassert (warnClause_isUndefined (warn));
   return (uentry_makeFunctionAux (n, t, 
                                  ((typeId_isInvalid (access)) ? typeIdSet_emptySet () 
                                   : typeIdSet_single (access)),
@@ -3662,7 +3683,6 @@ void uentry_addAccessType (uentry ue, typeId tid)
                                  FALSE, FALSE));
 }
 
-# ifndef NOLCL
 /*@notnull@*/ uentry 
   uentry_makePrivFunction2 (cstring n, ctype t, 
                            typeIdSet access, 
@@ -3691,7 +3711,6 @@ void uentry_addAccessType (uentry ue, typeId tid)
   reflectImplicitFunctionQualifiers (ue, TRUE);
   return (ue);
 }
-# endif
 
 uentry uentry_makeExpandedMacro (cstring s, fileloc f)
 {
@@ -3730,7 +3749,6 @@ bool uentry_isForward (uentry e)
   return FALSE;
 }
 
-# ifndef NOLCL
 /*@notnull@*/ uentry 
 uentry_makeTypeListFunction (cstring n, typeIdSet access, fileloc f)
 {
@@ -3751,7 +3769,6 @@ uentry_makeUnspecFunction (cstring n, ctype t,
   reflectImplicitFunctionQualifiers (ue, TRUE);
   return ue;
 }
-# endif
 
 /*
 ** datatypes
@@ -3760,7 +3777,7 @@ uentry_makeUnspecFunction (cstring n, ctype t,
 /* is exported for use by usymtab_interface */
 
 /*@notnull@*/ uentry 
-  uentry_makeDatatypeAux (cstring n, ctype t, ynm mut, ynm abstract, 
+  uentry_makeDatatypeAux (cstring n, ctype t, ynm mut, qual abstract, 
                          fileloc f, bool priv)
 {
   uentry e = uentry_alloc ();
@@ -3782,7 +3799,7 @@ uentry_makeUnspecFunction (cstring n, ctype t,
 
   uentry_setSpecDef (e, f);
 
-  e->warn = warnClause_undefined; /*@i634@*/ 
+  e->warn = warnClause_undefined; 
   e->uses = filelocList_new ();
   e->isPrivate = priv;
   e->hasNameError = FALSE;
@@ -3801,7 +3818,7 @@ uentry_makeUnspecFunction (cstring n, ctype t,
       uentry_setDefined (e, f);
     }
 
-  if (ynm_isOn (abstract) && !(uentry_isCodeDefined (e)))
+  if (qual_isAbstract (abstract) && !(uentry_isCodeDefined (e)))
     {
       sRef_setNullState (e->sref, NS_ABSNULL, uentry_whereDeclared (e));
     }
@@ -3810,12 +3827,12 @@ uentry_makeUnspecFunction (cstring n, ctype t,
 }
 
 /*@notnull@*/ uentry
-  uentry_makeDatatype (cstring n, ctype t, ynm mut, ynm abstract, fileloc f)
+  uentry_makeDatatype (cstring n, ctype t, ynm mut, qual abstract, fileloc f)
 {
   return (uentry_makeDatatypeAux (n, t, mut, abstract, f, FALSE));
 }
 
-/*@notnull@*/ uentry uentry_makeBoolDatatype (ynm abstract)
+/*@notnull@*/ uentry uentry_makeBoolDatatype (qual abstract)
 {
   uentry ret = uentry_makeDatatypeAux (context_getBoolName (),
                                       ctype_bool, NO, abstract, 
@@ -3846,7 +3863,7 @@ static /*@only@*/ /*@notnull@*/ uentry
 
   uentry_setSpecDef (e, f);
 
-  e->warn = warnClause_undefined; /*@i452@*/
+  e->warn = warnClause_undefined; 
   e->uses = filelocList_new ();
   e->isPrivate = FALSE;
   e->hasNameError = FALSE;
@@ -3891,8 +3908,8 @@ uentry_makeEndIterAux (cstring n, typeIdSet access, /*@only@*/ fileloc f)
   e->info->enditer = (ueinfo) dmalloc (sizeof (*e->info->enditer));
 
   e->info->enditer->access = access;
+  e->warn = warnClause_undefined; 
 
-  e->warn = warnClause_undefined; /*@i452@*/
   return (e);
 }
 
@@ -3936,10 +3953,10 @@ static /*@only@*/ /*@notnull@*/ uentry
 
   e->info = (uinfo) dmalloc (sizeof (*e->info));
   e->info->datatype = (udinfo) dmalloc (sizeof (*e->info->datatype));
-  e->info->datatype->abs = NO;
+  e->info->datatype->abs = qual_createUnknown ();
   e->info->datatype->mut = (kind == KENUMTAG) ? NO : MAYBE;
   e->info->datatype->type = t;
-  e->warn = warnClause_undefined; /*@i452@*/
+  e->warn = warnClause_undefined;
 
   if (uentry_isDeclared (e))
     {
@@ -3978,7 +3995,6 @@ uentry_makeUnionTag (cstring n, ctype t, fileloc loc)
   return (ret);
 }
 
-# ifndef NOLCL
 uentry
 uentry_makeEnumTag (cstring n, ctype t, fileloc loc)
 {
@@ -3988,7 +4004,6 @@ uentry_makeEnumTag (cstring n, ctype t, fileloc loc)
   cstring_free (ename);
   return ret;
 }
-# endif
 
 uentry
 uentry_makeUnionTagLoc (cstring n, ctype t)
@@ -4224,7 +4239,7 @@ uentry_compare (uentry u1, uentry u2)
                                    u2->info->datatype->type));
       COMPARERETURN (ynm_compare (u1->info->datatype->mut,
                                  u2->info->datatype->mut));
-      return (ynm_compare (u1->info->datatype->abs, u2->info->datatype->abs));
+      return (generic_compare (u1->info->datatype->abs, u2->info->datatype->abs));
     }
   
   BADEXIT;
@@ -4295,12 +4310,12 @@ static uentry
   e->used = FALSE;
   e->lset = FALSE;
 
-  e->warn = warnClause_undefined; /*@i452@*/
+  e->warn = warnClause_undefined; 
 
   e->info = (uinfo) dmalloc (sizeof (*e->info));
   e->info->uconst = (ucinfo) dmalloc (sizeof (*e->info->uconst));
   e->info->uconst->access = access;
-  e->info->uconst->macro = FALSE; /*@i523! fix this when macro info added to library */
+  e->info->uconst->macro = FALSE; /* fix this when macro info added to library */
   uentry_setConstantValue (e, m);
   sRef_storeState (e->sref);
 
@@ -4343,7 +4358,7 @@ static /*@only@*/ uentry
   e->lset = FALSE;
 
   e->uses = filelocList_new ();
-  e->warn = warnClause_undefined; /*@i452@*/
+  e->warn = warnClause_undefined; 
 
   e->info = (uinfo) dmalloc (sizeof (*e->info));
   e->info->var = (uvinfo) dmalloc (sizeof (*e->info->var));
@@ -4367,7 +4382,7 @@ static /*@only@*/ uentry
 }
 
 static /*@only@*/ uentry  
-uentry_makeDatatypeBase (/*@only@*/ cstring name, ctype ct, ynm abstract, 
+uentry_makeDatatypeBase (/*@only@*/ cstring name, ctype ct, qual abstract, 
                         ynm mut, ctype rtype, alkind ak, exkind exp, 
                         sstate defstate, nstate isnull,
                         /*@only@*/ fileloc loc)
@@ -4405,7 +4420,7 @@ uentry_makeDatatypeBase (/*@only@*/ cstring name, ctype ct, ynm abstract,
 
   sRef_setDefState (e->sref, defstate, loc);
 
-  if (ynm_isOn (abstract) && ctype_isUnknown (ct) && isnull == NS_UNKNOWN)
+  if (qual_isEitherAbstract (abstract) && ctype_isUnknown (ct) && isnull == NS_UNKNOWN)
     {
       isnull = NS_ABSNULL;
     }
@@ -4428,9 +4443,7 @@ uentry_makeDatatypeBase (/*@only@*/ cstring name, ctype ct, ynm abstract,
   
   e->isPrivate = FALSE;
   e->hasNameError = FALSE;
-
-  e->warn = warnClause_undefined; /*@i452@*/
-
+  e->warn = warnClause_undefined; 
   e->used = FALSE;
   e->lset = FALSE;
   e->uses = filelocList_new ();
@@ -4448,7 +4461,6 @@ uentry_makeDatatypeBase (/*@only@*/ cstring name, ctype ct, ynm abstract,
   return (e);
 }
 
-# ifndef NOLCL
 static void uentry_setHasGlobs (uentry ue)
 {
   llassert (uentry_isFunction (ue));
@@ -4462,7 +4474,6 @@ static void uentry_setHasMods (uentry ue)
 
   ue->info->fcn->hasMods = TRUE;
 }
-# endif
 
 bool uentry_hasGlobs (uentry ue)
 {
@@ -4638,11 +4649,11 @@ static /*@only@*/ uentry
   e->used = FALSE;
   e->lset = FALSE;
   e->uses = filelocList_new ();
-  e->warn = warnClause_undefined; /*@i452@*/
+  e->warn = warnClause_undefined; 
 
   e->info = (uinfo) dmalloc (sizeof (*e->info));
   e->info->datatype = (udinfo) dmalloc (sizeof (*e->info->datatype));
-  e->info->datatype->abs  = NO;
+  e->info->datatype->abs  = qual_createUnknown ();
   e->info->datatype->mut  = MAYBE;
   e->info->datatype->type = rtype;
 
@@ -4683,7 +4694,7 @@ static uentry
   e->used = FALSE;
   e->lset = FALSE;
   e->uses = filelocList_new ();
-  e->warn = warnClause_undefined; /*@i452@*/
+  e->warn = warnClause_undefined; 
 
   e->info = (uinfo) dmalloc (sizeof (*e->info));
   e->info->iter = (uiinfo) dmalloc (sizeof (*e->info->iter));
@@ -4727,7 +4738,7 @@ static uentry
   e->used = FALSE;
   e->lset = FALSE;
   e->uses = filelocList_new ();
-  e->warn = warnClause_undefined; /*@i452@*/
+  e->warn = warnClause_undefined; 
 
   e->info = (uinfo) dmalloc (sizeof (*e->info));
   e->info->enditer = (ueinfo) dmalloc (sizeof (*e->info->enditer));
@@ -4839,7 +4850,7 @@ uentry_undump (ekind kind, fileloc loc, char **s)
          break;
        case KDATATYPE: 
          {
-           ynm abstract;
+           qual abstract;
            ynm mut;
            ctype rtype;
            sstate defstate;
@@ -4847,7 +4858,7 @@ uentry_undump (ekind kind, fileloc loc, char **s)
            alkind aliased;
            exkind exp;
 
-           advanceField (s); abstract = ynm_fromCodeChar (reader_loadChar (s));
+           advanceField (s); abstract = qual_abstractFromCodeChar (reader_loadChar (s));
            advanceField (s); mut = ynm_fromCodeChar (reader_loadChar (s));
            advanceField (s); defstate = sstate_fromInt (reader_getInt (s));      
            advanceField (s); isnull = nstate_fromInt (reader_getInt (s));      
@@ -5116,7 +5127,7 @@ uentry_dumpAux (uentry v, bool isParam)
        else
          {
            sdump = message ("%d@%d@%d@%d@%d",  
-                    (int) dss,
+                            (int) dss,
                             (int) nst,
                             (int) alk,
                             (int) exk,
@@ -5149,9 +5160,9 @@ uentry_dumpAux (uentry v, bool isParam)
                ctype_unparse (v->utype), (int) v->utype));
       */
 
-      return (message ("%q@%s@%s@%d@%d@%d@%d@%q#%s", 
+      return (message ("%q@%c@%s@%d@%d@%d@%d@%q#%s", 
                       ctype_dump (v->utype),
-                      ynm_unparseCode (v->info->datatype->abs),
+                      qual_abstractCode (v->info->datatype->abs),
                       ynm_unparseCode (v->info->datatype->mut),
                       (int) sRef_getDefState (v->sref),
                       (int) sRef_getNullState (v->sref),
@@ -5320,8 +5331,8 @@ uentry_unparseFull (uentry v)
     {
       cstring res;
 
-      res = message ("[%w] %s %s: %s [spec: %q; decl: %q; def: %q]",
-                    (unsigned long) v, ekind_unparse (v->ukind), v->uname,
+      res = message ("[%p] %s %s: %s [spec: %q; decl: %q; def: %q]",
+                    v, ekind_unparse (v->ukind), v->uname,
                     ctype_unparse (v->utype),
                     fileloc_unparse (uentry_whereSpecified (v)),
                     fileloc_unparse (uentry_whereDeclared (v)),
@@ -5337,7 +5348,7 @@ uentry_unparseFull (uentry v)
                         (ctype_isDefined (v->info->datatype->type) 
                          ? v->info->datatype->type : ctype_unknown),
                         ynm_unparse (v->info->datatype->mut),
-                        ynm_unparse (v->info->datatype->abs),
+                        qual_unparse (v->info->datatype->abs),
                         sRef_unparseState (v->sref));
        }
       else if (uentry_isFunction (v))
@@ -5373,8 +5384,9 @@ uentry_unparseFull (uentry v)
        }
       else if (uentry_isConstant (v))
        {
-         res = message ("%q = %q",
-                        res, multiVal_unparse (uentry_getConstantValue (v)));
+         res = message ("%q = %q / %q",
+                        res, multiVal_unparse (uentry_getConstantValue (v)),
+                        sRef_unparseFull (v->sref));
        }
       else
        {
@@ -5476,10 +5488,10 @@ uentry_setAbstract (uentry e)
   typeId oldid;
 
   llassert (uentry_isDatatype (e) 
-           && (ynm_isMaybe (e->info->datatype->abs)));
+           && (qual_isUnknown (e->info->datatype->abs)));
 
   oldid = ctype_typeId (e->info->datatype->type);
-  e->info->datatype->abs = YES;
+  e->info->datatype->abs = qual_createAbstract ();
   e->info->datatype->type = ctype_createAbstract (oldid);
 }
 
@@ -5487,32 +5499,42 @@ void
 uentry_setConcrete (uentry e)
 {
   llassert (uentry_isDatatype (e) 
-           && (ynm_isMaybe (e->info->datatype->abs)));
+           && (qual_isUnknown (e->info->datatype->abs)
+               || qual_isConcrete (e->info->datatype->abs)));
 
-  e->info->datatype->abs = NO;
+  e->info->datatype->abs = qual_createConcrete ();
 }
 
 bool
 uentry_isAbstractDatatype (uentry e)
 {
   return (uentry_isDatatype (e) 
-         && (ynm_isOn (e->info->datatype->abs)));
+         && (qual_isEitherAbstract (e->info->datatype->abs)));
 }
 
 bool
 uentry_isMaybeAbstract (uentry e)
 {
   return (uentry_isDatatype (e) 
-         && (ynm_isMaybe (e->info->datatype->abs)));
+         && (!qual_isConcrete (e->info->datatype->abs)));
 }
 
 bool
 uentry_isMutableDatatype (uentry e)
 {
-  bool res = uentry_isDatatype (e) 
-    && (ynm_toBoolRelaxed (e->info->datatype->mut));
-  
-  return res;
+  if (uentry_isDatatype (e))
+    {
+      if (ctype_isNumAbstract (e->info->datatype->type)) 
+       {
+         return FALSE;
+       }
+      else
+       {
+         return ynm_toBoolRelaxed (e->info->datatype->mut);
+       }
+    }
+
+  return FALSE;
 }
 
 bool
@@ -5719,29 +5741,42 @@ uentry_getGlobs (uentry l)
       return globSet_undefined;
     }
 
-  if (l->ukind != KFCN)
+  if (uentry_isFunction (l))
+    {
+      return l->info->fcn->globs;
+    }
+  else if (uentry_isIter (l))
+    {
+      return l->info->iter->globs;
+    }
+  else if (uentry_isEndIter (l))
     {
-      if (l->ukind != KITER && l->ukind != KENDITER)
+      return globSet_undefined;
+    }
+  else
+    {
+      if (l->ukind == KVAR)
        {
-         if (l->ukind == KVAR)
-           {
-             llbug (message ("Bad call to uentry_getGlobs (var): %q (%s)", 
+         llcontbug (message ("Bad call to uentry_getGlobs (var): %q (%s)", 
                              uentry_unparse (l), 
                              ekind_unparse (l->ukind)));
-           }
-         else
-           {
-             llbug (message ("Bad call to uentry_getGlobs: %q (%s)", 
+       }
+      else
+       {
+         llcontbug (message ("Bad call to uentry_getGlobs: %q (%s)", 
                              uentry_unparse (l), 
                              ekind_unparse (l->ukind)));
-           }
        }
+
       return globSet_undefined;
     }
-
-  return l->info->fcn->globs;
 }
 
+# ifdef WIN32
+/* Make Microsoft VC++ happy */
+# pragma warning (disable : 4715) 
+# endif
+
 /*@observer@*/ sRefSet
 uentry_getMods (uentry l)
 {
@@ -5753,14 +5788,28 @@ uentry_getMods (uentry l)
       return sRefSet_undefined; 
     }
 
-  return l->info->fcn->mods;
+  if (uentry_isFunction (l))
+    {
+      return l->info->fcn->mods;
+    }
+  else if (uentry_isIter (l))
+    {
+      return l->info->iter->mods;
+    }
+  else if (uentry_isEndIter (l))
+    {
+      return sRefSet_undefined;
+    }
+  else
+    {
+      BADBRANCH;
+    }
 }
 
 ekind
 uentry_getKind (uentry e)
 {
   llassert (uentry_isValid (e));
-
   return (e->ukind);
 }
 
@@ -5795,7 +5844,13 @@ uentry_getParams (uentry l)
       {
        ctype ct = l->utype;
 
-       llassert (ctype_isFunction (ct));
+       /*drl 12/10/2002 changed to fix bug involving multiple redefines of library functions in macros.  Bug was reported by  Malcolm Parsons
+
+       Old code was  simplly llassert (ctype_isFunction (ct) );
+       */
+       
+       llassert (ctype_isFunction (ct) || context_inMacro() );
+       
        return (ctype_argsFunction (ct));
       }
     BADDEFAULT;
@@ -6179,7 +6234,8 @@ sRef uentry_getSref (uentry e)
 
 sRef uentry_getOrigSref (uentry e)
 {
-  /*@i523*/ /* evans 2001-09-09 - need to fix this 
+  /* evans 2003-04-12 - removed for now */
+  /* evans 2001-09-09 - need to fix this 
   if (uentry_isValid (e))
     {
       if (uentry_isVariable (e))
@@ -6379,14 +6435,18 @@ uentry_getAbstractType (uentry e)
 ctype uentry_getRealType (uentry e)
 {
   ctype ct;
-  typeId uid = USYMIDINVALID;
+  typeId uid = typeId_invalid;
 
   if (uentry_isInvalid (e))
     {
       return ctype_unknown;
     }
-
-  llassertprint (uentry_isDatatype (e), ("not datatype: %s", uentry_unparse (e)));
+  
+  if (!uentry_isDatatype (e))
+    {
+      /* This shouldn't happen, except when types are redeclared in strange ways */
+      return ctype_unknown;
+    }
 
   if (uentry_isAnyTag (e))
     {
@@ -6421,9 +6481,9 @@ ctype uentry_getRealType (uentry e)
   
   if (ctype_isUA (ct))
     {
-      usymId iid = ctype_typeId (ct);
+      typeId iid = ctype_typeId (ct);
       
-      if (usymId_equal (iid, uid))
+      if (typeId_equal (iid, uid))
        {         
          llcontbug (message ("uentry_getRealType: recursive type! %s",
                              ctype_unparse (ct)));
@@ -6452,7 +6512,7 @@ ctype uentry_getRealType (uentry e)
 ctype uentry_getForceRealType (uentry e)
 {
   ctype   ct;
-  typeId uid = USYMIDINVALID;
+  typeId uid = typeId_invalid;
 
   if (uentry_isInvalid (e))
     {
@@ -6486,9 +6546,9 @@ ctype uentry_getForceRealType (uentry e)
   
   if (ctype_isUA (ct))
     {
-      usymId iid = ctype_typeId (ct);
+      typeId iid = ctype_typeId (ct);
       
-      if (usymId_equal (iid, uid))
+      if (typeId_equal (iid, uid))
        {         
          llcontbug (message ("uentry_getRealType: recursive type! %s",
                              ctype_unparse (ct)));
@@ -6534,13 +6594,21 @@ uentry uentry_nameCopy (cstring name, uentry e)
 }
 
 void
-uentry_setDatatype (uentry e, usymId uid)
+uentry_setDatatype (uentry e, typeId uid)
 {
   llassert (uentry_isDatatype (e));
 
   if (uentry_isAbstractType (e))
     {
-      e->info->datatype->type = ctype_createAbstract (uid);
+      if (qual_isNumAbstract (e->info->datatype->abs)) 
+       {
+         e->info->datatype->type = ctype_createNumAbstract (uid);
+       }
+      else
+       {
+         llassert (qual_isAbstract (e->info->datatype->abs));
+         e->info->datatype->type = ctype_createAbstract (uid);
+       }
     }
   else
     {
@@ -6631,7 +6699,6 @@ uvinfo_copy (uvinfo u)
   ret->defstate = u->defstate;
   ret->checked = u->checked;
 
-  /*@i523 ret->origsref = sRef_copy (u->origsref); */
 
   /* drl added 07-02-001 */
   /* copy null terminated information */
@@ -6774,7 +6841,7 @@ uentry_reallyFree (/*@notnull@*/ /*@only@*/ uentry e)
 
   nuentries--;
   sfree (e);
-  }
+}
 
 extern void uentry_markOwned (/*@owned@*/ uentry u)
 {
@@ -6816,7 +6883,7 @@ KindConformanceError (/*@unique@*/ uentry old, uentry unew, bool mustConform)
   llassert (uentry_isValid (old));
   llassert (uentry_isValid (unew));
 
-  if (uentry_isEitherConstant (unew)
+  if ((uentry_isEitherConstant (unew) || uentry_isDatatype (unew))
       && (fileloc_isPreproc (uentry_whereDeclared (old))
          || ctype_isUnknown (old->utype))
       && !uentry_isSpecified (old))
@@ -7288,9 +7355,10 @@ checkEnumConformance (/*@notnull@*/ uentry old, /*@notnull@*/ uentry unew)
       if (optgenerror 
          (FLG_MATCHFIELDS,
           message ("Enum %q declared with members { %q } but "
-                   "specified with members { %q }",
+                   "%s with members { %q }",
                    uentry_getName (old), 
                    enumNameList_unparse (enew),
+                   uentry_specOrDefName (old),
                    enumNameList_unparse (eold)),
           uentry_whereDeclared (unew)))
        {
@@ -8239,6 +8307,29 @@ void uentry_checkMatchParam (uentry u1, uentry u2, int paramno, exprNode e)
     }
 }
 
+static void uentry_convertIntoFunction (/*@notnull@*/ uentry old)
+{
+  /*
+  ** Convert old into a function
+  */
+  
+  old->ukind = KFCN;
+  old->utype = ctype_unknown;
+  old->info->fcn = (ufinfo) dmalloc (sizeof (*old->info->fcn));
+  old->info->fcn->hasMods = FALSE;
+  old->info->fcn->hasGlobs = FALSE;
+  old->info->fcn->exitCode = XK_UNKNOWN;
+  old->info->fcn->nullPred = qual_createUnknown ();
+  old->info->fcn->specialCode = SPC_NONE;
+  old->info->fcn->access = typeIdSet_undefined;
+  old->info->fcn->globs = globSet_undefined;
+  old->info->fcn->defparams = uentryList_undefined;
+  old->info->fcn->mods = sRefSet_undefined;
+  old->info->fcn->specclauses = NULL;
+  old->info->fcn->preconditions = NULL;
+  old->info->fcn->postconditions = NULL;
+}
+
 static void
 checkFunctionConformance (/*@unique@*/ /*@notnull@*/ uentry old,
                          /*@notnull@*/ uentry unew, 
@@ -8268,8 +8359,26 @@ checkFunctionConformance (/*@unique@*/ /*@notnull@*/ uentry old,
   
   if (ctype_isKnown (oldType))
     {
-      llassert (ctype_isFunction (oldType));
-      oldRetType = ctype_getReturnType (oldType);
+      if (ctype_isFunction (oldType))
+       {
+         oldRetType = ctype_getReturnType (oldType);
+       }
+      else
+       {
+         if (optgenerror 
+             (FLG_INCONDEFS,
+              message ("%s %q declared as function, but previously declared as %s",
+                       ekind_capName (unew->ukind),
+                       uentry_getName (unew),
+                       ekind_unparseLong (old->ukind)),
+              uentry_whereDeclared (unew)))
+           {
+             uentry_showWhereLast (old);
+           }
+
+         uentry_convertIntoFunction (old);
+         return;
+       }
     }
 
   if (ctype_isKnown (newType))
@@ -8581,13 +8690,12 @@ checkFunctionConformance (/*@unique@*/ /*@notnull@*/ uentry old,
            }
          */
 
-         /*@i23 need checking @*/ 
-
+         /* need to add some checking @*/ 
          old->info->fcn->specclauses = unew->info->fcn->specclauses;
        }
       else
        {
-         /*@i43 should be able to append? @*/
+         /* should be able to append? */
 
          stateClauseList_checkEqual (old, unew);
          stateClauseList_free (unew->info->fcn->specclauses);
@@ -8595,7 +8703,7 @@ checkFunctionConformance (/*@unique@*/ /*@notnull@*/ uentry old,
          /*@-branchstate@*/ 
        }
     }
-  /*@=branchstate@*/ /*@i23 shouldn't need this@*/
+  /*@=branchstate@*/ /* shouldn't need this */
 
   if (fileloc_isUndefined (old->whereDeclared))
     {
@@ -8609,7 +8717,8 @@ checkFunctionConformance (/*@unique@*/ /*@notnull@*/ uentry old,
     {
       /* no change */
     }
-/*@i523 @*/ }
+  /*@-compmempass@*/
+} /*@=compmempass@*/ /* I think this is a spurious warning */
 
 void
 uentry_mergeConstantValue (uentry ue, /*@only@*/ multiVal m)
@@ -8826,10 +8935,10 @@ uentry_checkDatatypeConformance (/*@notnull@*/ uentry old,
        }
     }
   
-  if (unew->info->datatype->abs != MAYBE)
+  if (!qual_isUnknown (unew->info->datatype->abs))
     {
-      if (ynm_isOff (old->info->datatype->abs)
-         && ynm_isOn (unew->info->datatype->abs))
+      if (qual_isConcrete (old->info->datatype->abs)
+         && qual_isEitherAbstract (unew->info->datatype->abs))
        {
          if (!ctype_isDirectBool (old->utype))
            {
@@ -8845,8 +8954,8 @@ uentry_checkDatatypeConformance (/*@notnull@*/ uentry old,
                }
            }
        }
-      else if (ynm_isOn (old->info->datatype->abs)
-              && ynm_isOff (unew->info->datatype->abs))
+      else if (qual_isEitherAbstract (old->info->datatype->abs)
+              && qual_isConcrete (unew->info->datatype->abs))
        {
          if (!ctype_isDirectBool (old->utype))
            {
@@ -8869,7 +8978,7 @@ uentry_checkDatatypeConformance (/*@notnull@*/ uentry old,
     }
   else 
     {
-      if (ynm_isOn (old->info->datatype->abs))
+      if (qual_isEitherAbstract (old->info->datatype->abs))
        {
          old->sref = unew->sref;
          unew->info->datatype->mut = old->info->datatype->mut;
@@ -8918,7 +9027,7 @@ uentry_checkDatatypeConformance (/*@notnull@*/ uentry old,
     }
   else
     {
-      if (ynm_isOn (old->info->datatype->abs))
+      if (qual_isEitherAbstract (old->info->datatype->abs))
        {
          if (ynm_isOn (old->info->datatype->mut) && ynm_isOff (unew->info->datatype->mut))
            {
@@ -9527,7 +9636,22 @@ uentry_mergeDefinition (uentry old, /*@only@*/ uentry unew)
          uentry_convertVarFunction (old);
        }
 
-      llassert (uentry_isFunction (old));
+      if (!uentry_isFunction (old))
+       {
+         if (optgenerror 
+             (FLG_INCONDEFS,
+              message ("%s %q declared as function, but previously declared as %s",
+                       ekind_capName (unew->ukind),
+                       uentry_getName (unew),
+                       ekind_unparseLong (old->ukind)),
+              uentry_whereDeclared (unew)))
+           {
+             uentry_showWhereLast (old);
+           }
+
+         uentry_convertIntoFunction (old);
+         return;
+       }
     }
 
   DPRINTF (("uentry merge: %s / %s",
@@ -9818,12 +9942,12 @@ uentry_sameKind (uentry u1, uentry u2)
    
 static void uentry_updateInto (/*@unique@*/ uentry unew, uentry old)
 {
-  ekind okind = unew->ukind;
+  ekind okind;
   llassert (uentry_isValid (unew));
   llassert (uentry_isValid (old));
 
   DPRINTF (("Update into: %s / %s", uentry_unparseFull (unew), uentry_unparseFull (old)));
-
+  okind = unew->ukind;
   unew->ukind = old->ukind;
   llassert (cstring_equal (unew->uname, old->uname));
   unew->utype = old->utype;
@@ -9835,7 +9959,7 @@ static void uentry_updateInto (/*@unique@*/ uentry unew, uentry old)
     }
   else
     {
-      fileloc_free (unew->whereSpecified); /*@i523 why no error without this? */
+      fileloc_free (unew->whereSpecified);
       unew->whereSpecified = fileloc_copy (old->whereSpecified);
     }
 
@@ -9846,7 +9970,7 @@ static void uentry_updateInto (/*@unique@*/ uentry unew, uentry old)
     }
   else
     {
-      fileloc_free (unew->whereDefined); /*@i523 why no error without this? */
+      fileloc_free (unew->whereDefined); 
       unew->whereDefined = fileloc_copy (old->whereDefined);
     }
 
@@ -9857,7 +9981,7 @@ static void uentry_updateInto (/*@unique@*/ uentry unew, uentry old)
     }
   else
     {
-      fileloc_free (unew->whereDeclared); /*@i523 why no error without this? */
+      fileloc_free (unew->whereDeclared); 
       unew->whereDeclared = fileloc_copy (old->whereDeclared);
     }
 
@@ -9876,10 +10000,10 @@ static void uentry_updateInto (/*@unique@*/ uentry unew, uentry old)
   unew->info = uinfo_copy (old->info, old->ukind);
 }
 
-
-uentry
-uentry_copy (uentry e)
+static uentry
+uentry_copyAux (uentry e, bool saveCopy)
 {
+  
   if (uentry_isValid (e))
     {
       uentry enew = uentry_alloc ();
@@ -9892,7 +10016,15 @@ uentry_copy (uentry e)
       enew->whereDefined = fileloc_copy (e->whereDefined);
       enew->whereDeclared = fileloc_copy (e->whereDeclared);
       
-      enew->sref = sRef_saveCopy (e->sref); /* Memory leak! */
+      if (saveCopy)
+       {
+         enew->sref = sRef_saveCopy (e->sref); /* Memory leak! */
+       }
+      else
+       {
+         enew->sref = sRef_copy (e->sref);
+       }
+      
       enew->used = e->used;
       enew->lset = FALSE;
       enew->isPrivate = e->isPrivate;
@@ -9915,6 +10047,18 @@ uentry_copy (uentry e)
     }
 }
 
+uentry
+uentry_copy (uentry e)
+{
+  return uentry_copyAux (e, TRUE);
+}
+
+uentry
+uentry_copyNoSave (uentry e)
+{
+  return uentry_copyAux (e, FALSE);
+}
+
 void
 uentry_setState (uentry res, uentry other)
 {
@@ -9966,8 +10110,8 @@ uentry_mergeUses (uentry res, uentry other)
 */
 
 static void
-  branchStateError (/*@notnull@*/ uentry res, /*@notnull@*/ uentry other, 
-                   bool flip, clause cl, fileloc loc)
+branchStateError (/*@notnull@*/ uentry res, /*@notnull@*/ uentry other, 
+                 bool flip, clause cl, fileloc loc)
 {
   if (optgenerror 
       (FLG_BRANCHSTATE,
@@ -9977,18 +10121,43 @@ static void
                sRef_stateAltVerb (res->sref), clause_nameFlip (cl, !flip)),
        loc))
     {
+      DPRINTF (("Here: %s / %s", sRef_unparseFull (res->sref), sRef_unparseFull (other->sref)));
+
       if (sRef_isDead (res->sref))
        {
-         sRef_showStateInfo (res->sref);
+         if (sRef_hasStateInfoLoc (res->sref)) {
+           llgenindentmsg (message ("%s:", clause_nameFlip (cl, flip)), loc);
+           sRef_showStateInfo (res->sref);
+         }
+
+         if (sRef_hasStateInfoLoc (other->sref)) {
+           llgenindentmsg (message ("%s:", clause_nameFlip (cl, !flip)), loc);
+           sRef_showStateInfo (other->sref);
+         }
        }
       else if (sRef_isKept (res->sref))
        {
-         sRef_showAliasInfo (res->sref);
+         if (sRef_hasAliasInfoLoc (res->sref)) {
+           llgenindentmsg (message ("%s:", clause_nameFlip (cl, flip)), loc);
+           sRef_showAliasInfo (res->sref);
+         }
+
+         if (sRef_hasAliasInfoLoc (other->sref)) {
+           llgenindentmsg (message ("%s:", clause_nameFlip (cl, !flip)), loc);
+           sRef_showAliasInfo (other->sref);
+         }
        }
       else /* dependent */
        {
-         sRef_showAliasInfo (res->sref);
-         sRef_showAliasInfo (other->sref);
+         if (sRef_hasAliasInfoLoc (res->sref)) {
+           llgenindentmsg (message ("%s:", clause_nameFlip (cl, flip)), loc);
+           sRef_showAliasInfo (res->sref);
+         }
+
+         if (sRef_hasAliasInfoLoc (other->sref)) {
+           llgenindentmsg (message ("%s:", clause_nameFlip (cl, !flip)), loc);
+           sRef_showAliasInfo (other->sref);
+         }
        }
       
       sRef_setAliasKind (res->sref, AK_ERROR, fileloc_undefined);
@@ -10029,11 +10198,27 @@ static void
     {
       if (sRef_isDead (other->sref))
        {
-         sRef_showStateInfo (other->sref);
+         if (sRef_hasStateInfoLoc (other->sref)) {
+           llgenindentmsg (message ("%s:", clause_nameFlip (cl, flip)), loc);
+           sRef_showStateInfo (other->sref);
+         }
+
+         if (sRef_hasStateInfoLoc (res->sref)) {
+           llgenindentmsg (message ("%s:", clause_nameFlip (cl, !flip)), loc);
+           sRef_showStateInfo (res->sref);
+         }
        }
       else /* kept */
        {
-         sRef_showAliasInfo (other->sref);
+         if (sRef_hasAliasInfoLoc (other->sref)) {
+           llgenindentmsg (message ("%s:", clause_nameFlip (cl, flip)), loc);
+           sRef_showAliasInfo (other->sref);
+         }
+
+         if (sRef_hasAliasInfoLoc (res->sref)) {
+           llgenindentmsg (message ("%s:", clause_nameFlip (cl, !flip)), loc);
+           sRef_showAliasInfo (res->sref);
+         }
        }
       
       sRef_setAliasKind (res->sref, AK_ERROR, fileloc_undefined);
@@ -10070,8 +10255,8 @@ static bool uentry_relevantReference (sRef sr, bool flip)
 }
 
 static void
-uentry_mergeAliasStates (uentry res, uentry other, fileloc loc,
-                        bool mustReturn, bool flip, bool opt,
+uentry_mergeAliasStates (/*@notnull@*/ uentry res, /*@notnull@*/ uentry other, 
+                        fileloc loc, bool mustReturn, bool flip, bool opt,
                         clause cl)    
 {
   sRef rs = res->sref;
@@ -10125,7 +10310,7 @@ uentry_mergeAliasStates (uentry res, uentry other, fileloc loc,
                        }
                      else 
                        {
-                         branchStateError (res, other, flip, cl, loc);
+                         branchStateError (res, other, !flip, cl, loc); /* evans 2002-12-15: changed flip to !flip */
                        }
                    }
                }
@@ -10227,7 +10412,8 @@ uentry_mergeAliasStates (uentry res, uentry other, fileloc loc,
 }
 
 static void
-uentry_mergeValueStates (uentry res, uentry other, fileloc loc, bool mustReturn, /*@unused@*/ bool flip)
+uentry_mergeValueStates (/*@notnull@*/ uentry res, /*@notnull@*/ uentry other,
+                        fileloc loc, bool mustReturn, /*@unused@*/ bool flip)
 {
   valueTable rvalues;
   valueTable ovalues;
@@ -10254,10 +10440,7 @@ uentry_mergeValueStates (uentry res, uentry other, fileloc loc, bool mustReturn,
       ** Copy values from other
       */
       
-      /*@i$@#@*/
-      DPRINTF (("Has value table: %s", sRef_unparseFull (other->sref)));
-      DPRINTF (("No value table: %s", sRef_unparseFull (res->sref)));
-      ;
+      /* ??? */
     }
   else
     {
@@ -10330,8 +10513,6 @@ uentry_mergeValueStates (uentry res, uentry other, fileloc loc, bool mustReturn,
 
                if (nval == stateValue_error)
                  {
-                   /*@i32 print extra info for assignments@*/
-
                    if (uentry_isGlobalMarker (res))
                      {
                        if (optgenerror 
@@ -10406,7 +10587,8 @@ uentry_mergeValueStates (uentry res, uentry other, fileloc loc, bool mustReturn,
 
 
 static void
-uentry_mergeSetStates (uentry res, uentry other, /*@unused@*/ fileloc loc,
+uentry_mergeSetStates (/*@notnull@*/ uentry res,
+                      /*@notnull@*/ uentry other, /*@unused@*/ fileloc loc,
                       bool flip, clause cl)
 {
   if (cl == DOWHILECLAUSE)
@@ -10510,8 +10692,6 @@ void uentry_setUsed (uentry e, fileloc loc)
 
   if (uentry_isValid (e))
     {
-      int dp;
-
       if (warnClause_isDefined (e->warn))
        {
          flagSpec flg = warnClause_getFlag (e->warn);
@@ -10570,9 +10750,9 @@ void uentry_setUsed (uentry e, fileloc loc)
            }
        }
       
-      if ((dp = uentry_directParamNo (e)) >= 0)
+      if (usymId_isValid (usymtab_directParamNo (e)))
        {
-         uentry_setUsed (usymtab_getParam (dp), loc);
+         uentry_setUsed (usymtab_getParam (usymId_toInt (usymtab_directParamNo (e))), loc);
        }
       
       e->used = TRUE;
@@ -10611,7 +10791,7 @@ bool uentry_isReturned (uentry u)
              || u->info->var->kind == VKSEFRETPARAM));
 }
 
-/*@exposed@*/ sRef uentry_returnedRef (uentry u, exprNodeList args)
+/*@exposed@*/ sRef uentry_returnedRef (uentry u, exprNodeList args, fileloc loc)
 {
   llassert (uentry_isRealFunction (u));
 
@@ -10621,7 +10801,7 @@ bool uentry_isReturned (uentry u)
       sRef res = sRef_makeNew (ctype_getReturnType (u->utype), u->sref, u->uname);
 
       DPRINTF (("Returned: %s", sRef_unparseFull (res)));
-      sRef_setAllocated (res, g_currentloc);
+      sRef_setAllocated (res, loc);
 
       DPRINTF (("ensures clause: %s / %s", uentry_unparse (u), 
                stateClauseList_unparse (clauses)));
@@ -10646,7 +10826,7 @@ bool uentry_isReturned (uentry u)
                      if (modf != NULL)
                        {
                          sRef sr = sRef_fixBase (el, res);
-                         modf (sr, g_currentloc);
+                         modf (sr, loc);
                        }
                    }
                  else
@@ -10686,19 +10866,25 @@ bool uentry_isReturned (uentry u)
                      
                      usymtab_addForceMustAlias (tcref, tref); /* evans 2001-05-27 */
 
+                     if (sRef_isNew (tcref))
+                       {
+                         /* tcref->kind = SK_OBJECT; */ /*!! Not new anymore */
+                       }
+
                      if (sRef_isDead (tcref))
                        {
-                         sRef_setDefined (tcref, g_currentloc);
-                         sRef_setOnly (tcref, g_currentloc);
+                         sRef_setDefined (tcref, loc);
+                         sRef_setOnly (tcref, loc);
                        }
                      
                      if (sRef_isRefCounted (tcref))
                        {
                          /* could be a new ref now (but only if its returned) */
-                         sRef_setAliasKindComplete (tcref, AK_ERROR, g_currentloc);
+                         sRef_setAliasKindComplete (tcref, AK_ERROR, loc);
                        }
                      
                      sRef_makeSafe (tcref);
+                     DPRINTF (("Returns tcref / %s", sRef_unparseFull (tcref)));
                      prefs = sRefSet_insert (prefs, tcref);
                    }
                }
@@ -10717,13 +10903,13 @@ bool uentry_isReturned (uentry u)
            }
          else
            {
-             /* should this ever happen? */ /*@i534 evans 2001-05-27 */
+             /* should this ever happen? */
              res = sRefSet_mergeIntoOne (prefs);
            }
          
          if (nstate_isKnown (n))
            {
-             sRef_setNullState (res, n, g_currentloc);
+             sRef_setNullState (res, n, loc);
            }
        }
       else
@@ -10740,7 +10926,7 @@ bool uentry_isReturned (uentry u)
          
          if (sRef_isRefCounted (res))
            {
-             sRef_setAliasKind (res, AK_NEWREF, g_currentloc);
+             sRef_setAliasKind (res, AK_NEWREF, loc);
            }
        }
       
@@ -10751,7 +10937,7 @@ bool uentry_isReturned (uentry u)
          
          if (ctype_isAbstract (ct))
            {
-             sRef_setNotNull (res, g_currentloc);
+             sRef_setNotNull (res, loc);
            }
          else
            {
@@ -10761,18 +10947,18 @@ bool uentry_isReturned (uentry u)
                }
              else
                {
-                 sRef_setNotNull (res, g_currentloc);
+                 sRef_setNotNull (res, loc);
                }
            }
        }
       
       if (sRef_isRefCounted (res))
        {
-         sRef_setAliasKind (res, AK_NEWREF, g_currentloc);
+         sRef_setAliasKind (res, AK_NEWREF, loc);
        }
       else if (sRef_isKillRef (res))
        {
-         sRef_setAliasKind (res, AK_REFCOUNTED, g_currentloc);
+         sRef_setAliasKind (res, AK_REFCOUNTED, loc);
        }
       else
        {
@@ -10785,11 +10971,18 @@ bool uentry_isReturned (uentry u)
        {
          sRef_setAliasKind (res, 
                             alkind_fixImplicit (ak),
-                            g_currentloc);
+                            loc);
        }
       
       sRefSet_free (prefs);
-      
+
+      /*
+      if (sRef_isOnly (res))
+       {
+         sRef_setFresh (res, loc);
+       }
+      */
+
       DPRINTF (("Returns ref: %s", sRef_unparseFull (res)));
       return res;
     }
@@ -11061,7 +11254,7 @@ void uentry_checkName (uentry ue)
   fileloc_free (tloc);
   uentry_setHasNameError (ue);
   
-  if (context_getFlag (FLG_REPEATUNRECOG))
+  if (context_getFlag (FLG_REPEATUNRECOG) || (context_inOldStyleScope()))
     {
       uentry_markOwned (ue);
     }
@@ -11116,20 +11309,19 @@ effects: sets the state of the variable
 */
 
 
-void uentry_setPossiblyNullTerminatedState (uentry p_e)  {
-  /*@access sRef@*/ /*i523 shouldn't do this! */
-  if( uentry_isValid(p_e) ) {
-    if( p_e->info != NULL) {
-      if( p_e->info->var != NULL) {
-         p_e->info->var->bufinfo->bufstate = BB_POSSIBLYNULLTERMINATED;
-         p_e->sref->bufinfo.bufstate = BB_POSSIBLYNULLTERMINATED;
-         return;
-      }
-    }
-  }
-  /*@noaccess sRef@*/
+void uentry_setPossiblyNullTerminatedState (uentry p_e)  
+{
+  llassert (uentry_isValid (p_e));
 
-  fprintf(stderr, "uentry:Error in setPossiblyNullTerminatedState\n");
+  if (p_e->info != NULL)
+    {
+      if (p_e->info->var != NULL) 
+       {
+         llassert (p_e->info->var->bufinfo != NULL);
+         p_e->info->var->bufinfo->bufstate = BB_POSSIBLYNULLTERMINATED;
+         sRef_setPossiblyNullTerminatedState (p_e->sref);
+       }
+    }
 }
 
 /*
@@ -11139,19 +11331,17 @@ effects: sets the size of the buffer
 */
 
 void uentry_setNullTerminatedState (uentry p_e)  {
-  if( uentry_isValid(p_e) ) {
-    if( p_e->info != NULL) {
-      if( p_e->info->var != NULL) {
-        p_e->info->var->bufinfo->bufstate = BB_NULLTERMINATED;
-       /*@access sRef@*/ /*@i523 bad!*/
-        p_e->sref->bufinfo.bufstate = BB_NULLTERMINATED;
-       /*@noaccess sRef@*/ 
-        return;
-      }
-    }
-  }
+  llassert (uentry_isValid (p_e));
 
-  fprintf(stderr, "uentry:Error in setNullTerminatedState\n");
+  if (p_e->info != NULL)
+    {
+      if (p_e->info->var != NULL)
+       {
+         llassert (p_e->info->var->bufinfo != NULL);
+         p_e->info->var->bufinfo->bufstate = BB_NULLTERMINATED;
+         sRef_setNullTerminatedState (p_e->sref);
+       }
+    }
 }
 
 /*
@@ -11160,43 +11350,40 @@ modifies: p_e
 effects: sets the size of the buffer
 */
 
-void uentry_setSize (uentry p_e, int size)  {
-  if( uentry_isValid(p_e) ) {
-    if( p_e->info != NULL) {
-      if( p_e->info->var != NULL) {
-        p_e->info->var->bufinfo->size = size;
-       /*@access sRef@*/ /*@i523 bad!*/
-        p_e->sref->bufinfo.size = size;
-       /*@noaccess sRef@*/
-        return;
-      }
+void uentry_setSize (uentry p_e, int size)  
+{
+  if (uentry_isValid (p_e))
+    {
+      if (p_e->info != NULL) 
+       {
+         if (p_e->info->var != NULL) 
+           {
+             llassert (p_e->info->var->bufinfo != NULL);
+             p_e->info->var->bufinfo->size = size;
+             sRef_setSize (p_e->sref, size);
+           }
+       }
     }
-  }
-
-  fprintf(stderr, "uentry:Error in setSize\n");
 }
 
-
 /*
 requires: p_e is defined, is a ptr/array variable 
 modifies: p_e
 effects: sets the length of the buffer
 */
 
-void uentry_setLen (uentry p_e, int len)  {
-  if( uentry_isValid(p_e) ) {
-    if( p_e->info != NULL) {
-      if( p_e->info->var != NULL) {
-        p_e->info->var->bufinfo->len = len;
-       /*@access sRef@*/ /*@i523 bad!*/
-        p_e->sref->bufinfo.len = len;
-       /*@noaccess sRef@*/
-        return;
-      }
+void uentry_setLen (uentry p_e, int len)  
+{
+  if (uentry_isValid (p_e)) 
+    {
+      if (p_e->info != NULL
+         && p_e->info->var != NULL) 
+       {
+         llassert (p_e->info->var->bufinfo != NULL);
+         p_e->info->var->bufinfo->len = len;
+         sRef_setLen (p_e->sref, len);
+       }
     }
-  }
-  
-  fprintf(stderr, "uentry:Error in setLen\n");
 }
 
 /*@=type*/
@@ -11218,3 +11405,47 @@ metaStateConstraintList uentry_getMetaStateEnsures (uentry e)
   llassert (uentry_isValid (e) && uentry_isFunction (e));
   return functionConstraint_getMetaStateConstraints (e->info->fcn->postconditions);
 }
+
+
+bool uentry_hasBufStateInfo (uentry ue)
+{
+  llassert (uentry_isValid (ue));
+  return (ue->info->var->bufinfo != NULL);
+}
+
+bool uentry_isNullTerminated (uentry ue)
+{
+  llassert (uentry_hasBufStateInfo (ue));
+  llassert (ue->info->var->bufinfo != NULL);
+  return ue->info->var->bufinfo->bufstate == BB_NULLTERMINATED;
+}
+
+bool uentry_isPossiblyNullTerminated (uentry ue)
+{
+  llassert (uentry_hasBufStateInfo (ue));
+  llassert (ue->info->var->bufinfo != NULL);
+  return (ue->info->var->bufinfo->bufstate == BB_POSSIBLYNULLTERMINATED);
+}
+
+bool uentry_isNotNullTerminated (uentry ue)
+{
+  llassert (uentry_hasBufStateInfo (ue));
+  llassert (ue->info->var->bufinfo != NULL);
+  return (ue->info->var->bufinfo->bufstate == BB_NOTNULLTERMINATED);
+}
+
+# ifdef DEBUGSPLINT
+
+/*
+** For debugging only
+*/
+
+void uentry_checkValid (uentry ue)
+{
+  if (uentry_isValid (ue))
+    {
+      sRef_checkCompletelyReasonable (ue->sref);
+    }
+}
+
+# endif
This page took 0.847099 seconds and 4 git commands to generate.