]> andersk Git - splint.git/blobdiff - src/uentry.c
Fix DPRINTF bit rot.
[splint.git] / src / uentry.c
index 29277a374e015a7df6f76c2cb3dbb0bccf9e6100..6f6c090418b3d845ba98e15c61dbd242a24f8d22 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
@@ -108,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++;
   
@@ -712,11 +712,12 @@ bool uentry_isUnnamedVariable (uentry ue)
 {
   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))
        {
@@ -752,6 +753,10 @@ void uentry_checkParams (uentry ue)
                  
                  if (ctype_isFixedArray (ct))
                    {
+                     DPRINTF (("Array: %s / %s",
+                               ctype_unparse (ct),
+                               ctype_unparse (ctype_baseArrayPtr (ct))));
+
                      if (ctype_isArray (ctype_baseArrayPtr (ct))
                          && !ctype_isFixedArray (ctype_baseArrayPtr (ct)))
                        {
@@ -894,7 +899,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. */
                            }
@@ -925,9 +931,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))
     {
@@ -1103,7 +1107,7 @@ static void uentry_reflectClauses (uentry ue, functionClauseList clauses)
              **
              */
 
-             uentry_combineModifies (ue, modifiesClause_takeMods (mlc)); /*@i32@*/
+             uentry_combineModifies (ue, modifiesClause_takeMods (mlc)); 
            }
          else
            {
@@ -1312,7 +1316,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;
@@ -1473,8 +1477,7 @@ 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);
     }
@@ -1484,7 +1487,7 @@ 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);
@@ -2346,6 +2349,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))
@@ -2358,7 +2362,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))
@@ -2497,7 +2503,7 @@ uentry_reflectOtherQualifier (/*@notnull@*/ uentry ue, qual qel)
                        uentry_unparse (ue)),
               uentry_whereLast (ue)))
            {
-             /*@i! annotationInfo_showContextError (ainfo, ue); */
+             /* annotationInfo_showContextError (ainfo, ue); */
            }
        }
     }
@@ -3066,41 +3072,48 @@ uentry_isSpecialFunction (uentry ue)
 /*@notnull@*/ uentry uentry_makeParam (idDecl t, int i)
 {
   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)));
+  DPRINTF (("Base: %s [%d]", ctype_unparse (ct), ctype_isFixedArray (ct)));
   uentry_reflectQualifiers (ue, idDecl_getQuals (t));
   uentry_implicitParamAnnots (ue);
 
-  /* Parameter type [][] or [x][] is invalid */
+  if (ctype_isArray (ct)) 
+    {
+      /* Parameter type [][] or [x][] is invalid, but [][x] is okay */
+      ctype base = ctype_baseArrayPtr (ct);
 
-  while (ctype_isFixedArray (base)) {
-    base = ctype_baseArrayPtr (base);
-  }
-  
-  if (ctype_isIncompleteArray (base)) {
-    base = ctype_baseArrayPtr (base);
-
-    if (ctype_isArray (base)) {
-      if (!uentry_hasName (ue)) {
-       (void) optgenerror (FLG_INCOMPLETETYPE, 
-                           message ("Unnamed function parameter %d is incomplete type (inner array must have bounds): %s",
-                                    i + 1,
-                                    ctype_unparse (ct)),
-                           uentry_whereLast (ue));
-      } else {
-       (void) optgenerror (FLG_INCOMPLETETYPE, 
-                           message ("Function parameter %q is incomplete type (inner array must have bounds): %s",
-                                    uentry_getName (ue),
-                                    ctype_unparse (ct)),
-                           uentry_whereLast (ue));
-      }
+      DPRINTF (("Check array: %s / Base: %s", ctype_unparse (ct),
+               ctype_unparse (base)));
+      
+      if (ctype_isIncompleteArray (base)) 
+       {
+         if (!uentry_hasName (ue)) 
+           {
+             voptgenerror 
+               (FLG_INCOMPLETETYPE, 
+                message ("Unnamed function parameter %d is incomplete type "
+                         "(inner array must have bounds): %s",
+                         i + 1,
+                         ctype_unparse (ct)),
+                uentry_whereLast (ue));
+           } 
+         else 
+           {
+             voptgenerror 
+               (FLG_INCOMPLETETYPE, 
+                message ("Function parameter %q is incomplete type "
+                         "(inner array must have bounds): %s",
+                         uentry_getName (ue),
+                         ctype_unparse (ct)),
+                uentry_whereLast (ue));
+           }
+       }
     }
-  }
-
+  
   DPRINTF (("Param: %s", uentry_unparseFull (ue)));
   return ue;
 }
@@ -3150,7 +3163,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);
 
@@ -3311,7 +3324,7 @@ uentry uentry_makeVariableAux (cstring n, ctype t,
 
   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;
 
@@ -3326,7 +3339,7 @@ uentry uentry_makeVariableAux (cstring n, ctype t,
   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)));
@@ -3344,7 +3357,6 @@ uentry uentry_makeVariableAux (cstring n, ctype t,
       sRef_setStateFromType (e->sref, rt);
     }
 
-  DPRINTF (("Here we are: %s", sRef_unparseFull (e->sref)));
   e->info->var->defstate = sRef_getDefState (e->sref);  
   e->info->var->nullstate = sRef_getNullState (e->sref);
 
@@ -3355,7 +3367,7 @@ uentry uentry_makeVariableAux (cstring n, ctype t,
   
   if (ctype_isArray (t) || ctype_isPointer(t))
     {
-      /*@i222@*/ e->info->var->bufinfo = dmalloc (sizeof (*e->info->var->bufinfo));
+      e->info->var->bufinfo = dmalloc (sizeof (*e->info->var->bufinfo));
       e->info->var->bufinfo->bufstate = BB_NOTNULLTERMINATED;
       sRef_setNotNullTerminatedState (s);
     } 
@@ -3365,6 +3377,8 @@ uentry uentry_makeVariableAux (cstring n, ctype t,
     }/* end else */
   /* end modification */
 
+  DPRINTF (("New variable: %s", sRef_unparseFull (e->sref)));
+
   return (e);
 }
 
@@ -3672,7 +3686,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)),
@@ -3775,7 +3789,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 ();
@@ -3797,7 +3811,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;
@@ -3816,7 +3830,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));
     }
@@ -3825,12 +3839,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, 
@@ -3861,7 +3875,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;
@@ -3906,8 +3920,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);
 }
 
@@ -3951,10 +3965,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))
     {
@@ -4237,7 +4251,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;
@@ -4308,12 +4322,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);
 
@@ -4356,7 +4370,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));
@@ -4380,7 +4394,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)
@@ -4418,7 +4432,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;
     }
@@ -4441,9 +4455,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 ();
@@ -4649,11 +4661,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;
 
@@ -4694,7 +4706,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));
@@ -4738,7 +4750,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));
@@ -4850,7 +4862,7 @@ uentry_undump (ekind kind, fileloc loc, char **s)
          break;
        case KDATATYPE: 
          {
-           ynm abstract;
+           qual abstract;
            ynm mut;
            ctype rtype;
            sstate defstate;
@@ -4858,7 +4870,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));      
@@ -5127,7 +5139,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,
@@ -5160,9 +5172,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),
@@ -5331,8 +5343,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)),
@@ -5348,7 +5360,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))
@@ -5488,10 +5500,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);
 }
 
@@ -5499,32 +5511,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
@@ -5762,6 +5784,11 @@ uentry_getGlobs (uentry l)
     }
 }
 
+# ifdef WIN32
+/* Make Microsoft VC++ happy */
+# pragma warning (disable : 4715) 
+# endif
+
 /*@observer@*/ sRefSet
 uentry_getMods (uentry l)
 {
@@ -5795,7 +5822,6 @@ ekind
 uentry_getKind (uentry e)
 {
   llassert (uentry_isValid (e));
-
   return (e->ukind);
 }
 
@@ -6220,7 +6246,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))
@@ -6420,14 +6447,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))
     {
@@ -6462,9 +6493,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)));
@@ -6493,7 +6524,7 @@ ctype uentry_getRealType (uentry e)
 ctype uentry_getForceRealType (uentry e)
 {
   ctype   ct;
-  typeId uid = USYMIDINVALID;
+  typeId uid = typeId_invalid;
 
   if (uentry_isInvalid (e))
     {
@@ -6527,9 +6558,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)));
@@ -6575,13 +6606,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
     {
@@ -6672,7 +6711,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 */
@@ -8281,6 +8319,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, 
@@ -8310,8 +8371,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))
@@ -8623,13 +8702,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);
@@ -8637,7 +8715,7 @@ checkFunctionConformance (/*@unique@*/ /*@notnull@*/ uentry old,
          /*@-branchstate@*/ 
        }
     }
-  /*@=branchstate@*/ /*@i23 shouldn't need this@*/
+  /*@=branchstate@*/ /* shouldn't need this */
 
   if (fileloc_isUndefined (old->whereDeclared))
     {
@@ -8651,7 +8729,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)
@@ -8868,10 +8947,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))
            {
@@ -8887,8 +8966,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))
            {
@@ -8911,7 +8990,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;
@@ -8960,7 +9039,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))
            {
@@ -9411,8 +9490,7 @@ uentry_mergeEntries (uentry spec, /*@only@*/ uentry def)
       llassert (uentry_isFunction (spec));
     }
   
-  DPRINTF (("Merge entries: %s / %s",
-           uentry_unparseFull (spec),
+  DPRINTF (("Merge entries: %s / %s", uentry_unparseFull (spec),
            uentry_unparseFull (def)));
 
   uentry_mergeConstraints (spec, def);
@@ -9569,7 +9647,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",
@@ -9877,7 +9970,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);
     }
 
@@ -9888,7 +9981,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);
     }
 
@@ -9899,7 +9992,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);
     }
 
@@ -10039,20 +10132,43 @@ branchStateError (/*@notnull@*/ uentry res, /*@notnull@*/ uentry other,
                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);
-         sRef_showStateInfo (other->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);
-         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);
+         }
        }
       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);
@@ -10093,11 +10209,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);
@@ -10189,7 +10321,7 @@ uentry_mergeAliasStates (/*@notnull@*/ uentry res, /*@notnull@*/ uentry other,
                        }
                      else 
                        {
-                         branchStateError (res, other, flip, cl, loc);
+                         branchStateError (res, other, !flip, cl, loc); /* evans 2002-12-15: changed flip to !flip */
                        }
                    }
                }
@@ -10319,10 +10451,7 @@ uentry_mergeValueStates (/*@notnull@*/ uentry res, /*@notnull@*/ uentry other,
       ** Copy values from other
       */
       
-      /*@i$@#@*/
-      DPRINTF (("Has value table: %s", sRef_unparseFull (other->sref)));
-      DPRINTF (("No value table: %s", sRef_unparseFull (res->sref)));
-      ;
+      /* ??? */
     }
   else
     {
@@ -10395,8 +10524,6 @@ uentry_mergeValueStates (/*@notnull@*/ uentry res, /*@notnull@*/ uentry other,
 
                if (nval == stateValue_error)
                  {
-                   /*@i32 print extra info for assignments@*/
-
                    if (uentry_isGlobalMarker (res))
                      {
                        if (optgenerror 
@@ -10576,8 +10703,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);
@@ -10636,9 +10761,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;
@@ -10677,207 +10802,6 @@ bool uentry_isReturned (uentry u)
              || u->info->var->kind == VKSEFRETPARAM));
 }
 
-/*@i52323@*/
-# if 0
-/*@exposed@*/ sRef uentry_returnedRef (uentry u, exprNodeList args)
-{
-  llassert (uentry_isRealFunction (u));
-
-  if (ctype_isFunction (u->utype) && sRef_isStateSpecial (uentry_getSref (u)))
-    {
-      stateClauseList clauses = uentry_getStateClauseList (u);
-      sRef res = sRef_makeNew (ctype_getReturnType (u->utype), u->sref, u->uname);
-
-      DPRINTF (("Returned: %s", sRef_unparseFull (res)));
-      sRef_setAllocated (res, g_currentloc);
-
-      DPRINTF (("ensures clause: %s / %s", uentry_unparse (u), 
-               stateClauseList_unparse (clauses)));
-
-      /*
-      ** This should be in exprNode_reflectEnsuresClause
-      */
-
-      stateClauseList_postElements (clauses, cl)
-       {
-         if (!stateClause_isGlobal (cl))
-           {
-             sRefSet refs = stateClause_getRefs (cl);
-             sRefMod modf = stateClause_getEffectFunction (cl);
-             
-             sRefSet_elements (refs, el)
-               {
-                 sRef base = sRef_getRootBase (el);
-                 
-                 if (sRef_isResult (base))
-                   {
-                     if (modf != NULL)
-                       {
-                         sRef sr = sRef_fixBase (el, res);
-                         modf (sr, g_currentloc);
-                       }
-                   }
-                 else
-                   {
-                     ;
-                   }
-               } end_sRefSet_elements ;
-           }
-       } end_stateClauseList_postElements ;
-       
-      return res;
-    }
-  else
-    {
-      uentryList params;
-      alkind ak;
-      sRefSet prefs = sRefSet_new ();
-      sRef res = sRef_undefined;
-      sRef tcref = sRef_undefined;
-      sRef tref = sRef_undefined;
-      int paramno = 0;
-      
-      params = uentry_getParams (u);
-
-      /*
-      ** Setting up aliases has to happen *after* setting null state!
-      */
-
-      uentryList_elements (params, current)
-       {
-         if (uentry_isReturned (current))
-           {
-             if (exprNodeList_size (args) >= paramno)
-               {
-                 exprNode ecur = exprNodeList_nth (args, paramno);
-                 tref = exprNode_getSref (ecur);
-                 
-                 DPRINTF (("Returned reference: %s", sRef_unparseFull (tref)));
-
-                 if (sRef_isValid (tref))
-                   {
-                     tcref = sRef_copy (tref);
-                     
-                     if (sRef_isDead (tcref))
-                       {
-                         sRef_setDefined (tcref, g_currentloc);
-                         sRef_setOnly (tcref, g_currentloc);
-                       }
-                     
-                     if (sRef_isRefCounted (tcref))
-                       {
-                         /* could be a new ref now (but only if its returned) */
-                         sRef_setAliasKindComplete (tcref, AK_ERROR, g_currentloc);
-                       }
-                     
-                     sRef_makeSafe (tcref);
-                     prefs = sRefSet_insert (prefs, tcref);
-                   }
-               }
-           }
-         
-         paramno++;
-       } end_uentryList_elements ;
-
-      if (sRefSet_size (prefs) > 0)
-       {
-         nstate n = sRef_getNullState (u->sref);
-
-         if (sRefSet_size (prefs) == 1)
-           {
-             sRef rref = sRefSet_choose (prefs);
-             tref = rref;
-             res = sRef_makeType (sRef_getType (rref));
-             sRef_copyState (res, tref);
-           }
-         else
-           {
-             /* should this ever happen? */ /*@i534 evans 2001-05-27 */
-             res = sRefSet_mergeIntoOne (prefs);
-           }
-         
-         if (nstate_isKnown (n))
-           {
-             sRef_setNullState (res, n, g_currentloc);
-             DPRINTF (("Setting null: %s", sRef_unparseFull (res)));
-           }
-       }
-      else
-       {
-         if (ctype_isFunction (u->utype))
-           {
-             DPRINTF (("Making new from %s  -->", uentry_unparseFull (u)));
-             res = sRef_makeNew (ctype_getReturnType (u->utype), u->sref, u->uname);
-           }
-         else
-           {
-             DPRINTF (("Making new from %s  -->", uentry_unparseFull (u)));
-             res = sRef_makeNew (ctype_unknown, u->sref, u->uname);
-           }
-         
-         if (sRef_isRefCounted (res))
-           {
-             sRef_setAliasKind (res, AK_NEWREF, g_currentloc);
-           }
-       }
-      
-      if (sRef_getNullState (res) == NS_ABSNULL)
-       {
-         ctype ct = ctype_realType (u->utype);
-         
-         if (ctype_isAbstract (ct))
-           {
-             sRef_setNotNull (res, g_currentloc);
-           }
-         else
-           {
-             if (ctype_isUser (ct))
-               {
-                 sRef_setStateFromUentry (res, usymtab_getTypeEntry (ctype_typeId (ct)));
-               }
-             else
-               {
-                 sRef_setNotNull (res, g_currentloc);
-               }
-           }
-       }
-      
-      if (sRef_isRefCounted (res))
-       {
-         sRef_setAliasKind (res, AK_NEWREF, g_currentloc);
-       }
-      else if (sRef_isKillRef (res))
-       {
-         sRef_setAliasKind (res, AK_REFCOUNTED, g_currentloc);
-       }
-      else
-       {
-         ;
-       }
-      
-      ak = sRef_getAliasKind (res);
-      
-      if (alkind_isImplicit (ak))
-       {
-         sRef_setAliasKind (res, alkind_fixImplicit (ak), g_currentloc);
-       }
-
-# if 0
-      DPRINTF (("Aliasing: %s / %s", sRef_unparseFull (res), sRef_unparseFull (tref)));
-      usymtab_addReallyForceMustAlias (tref, res); /* evans 2001-05-27 */
-
-      /* evans 2002-03-03 - need to be symettric explicitly, since its not a local now */
-      usymtab_addReallyForceMustAlias (res, tref);
-# endif
-
-      sRefSet_free (prefs);
-      
-      DPRINTF (("Returns ref: %s", sRef_unparseFull (res)));
-      return res;
-    }
-}
-# endif
-
 /*@exposed@*/ sRef uentry_returnedRef (uentry u, exprNodeList args, fileloc loc)
 {
   llassert (uentry_isRealFunction (u));
@@ -10990,7 +10914,7 @@ bool uentry_isReturned (uentry u)
            }
          else
            {
-             /* should this ever happen? */ /*@i534 evans 2001-05-27 */
+             /* should this ever happen? */
              res = sRefSet_mergeIntoOne (prefs);
            }
          
@@ -11493,6 +11417,34 @@ metaStateConstraintList uentry_getMetaStateEnsures (uentry 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
 
 /*
This page took 0.085925 seconds and 4 git commands to generate.