]> andersk Git - splint.git/blobdiff - src/usymtab.c
Fixed problem with NULL being changed.
[splint.git] / src / usymtab.c
index 967606ed82bcd157bd862f3dbb650236580043fc..1d26d49de9f168f7d634709a2b73acf6e7ee21f4 100644 (file)
@@ -1,6 +1,6 @@
 /*
-** LCLint - annotation-assisted static program checker
-** Copyright (C) 1994-2001 University of Virginia,
+** Splint - annotation-assisted static program checker
+** 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,9 +17,9 @@
 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 ** MA 02111-1307, USA.
 **
-** For information on lclint: lclint-request@cs.virginia.edu
-** To report a bug: lclint-bug@cs.virginia.edu
-** For more information: http://lclint.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
 */
 /*
 ** usymtab
 **                      weird C syntax.
 */
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "basic.h"
 # include "structNames.h"
 # include "exprChecks.h"
 # include "transferChecks.h"
 
+/* Needed to install macros when loading libraries */
+
+# include "cpplib.h"
+# include "cpperror.h"
+# include "cpphash.h"
+
 /*
 ** Keep track of type definitions inside a function.
 */
@@ -99,6 +105,10 @@ static bool usymtab_isAltDefinitelyNull (sRef p_s) /*@globals utab@*/ ;
 static void refTable_free (/*@only@*/ /*@null@*/ refTable p_x, int p_nentries);
 static ctype usymtab_suFieldsType (uentryList p_f, bool p_isStruct) /*@globals globtab@*/ ;
 
+static void usymtab_freeAux (/*@only@*/ usymtab p_u)
+     /*@globals globtab, utab, filetab@*/
+     /*@modifies p_u@*/ ;
+
 extern int usymtab_getCurrentDepth (void) /*@globals utab@*/ 
 {
   return utab->lexlevel;
@@ -112,10 +122,15 @@ static bool usymtab_isDefinitelyNullAux (sRef p_s) /*@globals utab@*/ ;
 static /*@only@*/ cstring usymtab_unparseStackTab (usymtab p_t);
 static /*@exposed@*/ /*@dependent@*/ uentry 
   usymtab_getRefTab (/*@notnull@*/ usymtab p_u, int p_level, usymId p_index);
+
+# ifdef S_SPLINT_S
+/* These are not used anymore... */
 static /*@unused@*/ /*@only@*/ cstring 
   usymtab_unparseLocalAux (/*@notnull@*/ usymtab p_s);
 static /*@unused@*/ /*@only@*/ cstring 
   usymtab_unparseLocalList (/*@notnull@*/ usymtab p_s);
+# endif
+
 static /*@only@*/ cstring usymtab_typeName (/*@notnull@*/ usymtab p_t);
 static void usymtab_handleParams (void)
    /*@globals utab, globtab, filetab@*/ 
@@ -137,14 +152,19 @@ static /*@exposed@*/ /*@dependent@*/ uentry
 static /*@exposed@*/ /*@dependent@*/ uentry 
   usymtab_lookupQuietNoAlt (usymtab p_s, cstring p_k);
 
-static void usymtab_printAllAux (usymtab p_s) /*@modifies g_msgstream@*/ ;
-static int usymtab_getIndex (/*@notnull@*/ usymtab p_s, cstring p_k);
-static /*@exposed@*/ uentry usymtab_fetchIndex (/*@notnull@*/ usymtab p_s, int p_i);
-static /*@exposed@*/ uentry 
-  usymtab_lookupAux (usymtab p_s, cstring p_k);
-static /*@exposed@*/ /*@dependent@*/ /*@notnull@*/ usymtab 
-  usymtab_getFileTab (void) /*@globals filetab@*/ ;
-static int refTable_lookup (/*@notnull@*/ usymtab p_ut, int p_level, int p_index);
+static void usymtab_printAllAux (usymtab p_s) /*@modifies g_warningstream@*/ ;
+
+/*@function bool usymtab_indexFound (usymId) @*/
+# define usymtab_indexFound(u) ((u) != usymId_notfound)
+
+static usymId usymtab_getIndex (/*@notnull@*/ usymtab p_s, cstring p_k);
+static /*@exposed@*/ uentry usymtab_fetchIndex (/*@notnull@*/ usymtab p_s, usymId p_ui);
+static /*@exposed@*/ uentry usymtab_lookupAux (usymtab p_s, cstring p_k);
+
+static /*@exposed@*/ /*@dependent@*/ /*@notnull@*/ 
+   usymtab usymtab_getFileTab (void) /*@globals filetab@*/ ;
+
+static int refTable_lookup (/*@notnull@*/ usymtab p_ut, int p_level, usymId p_index);
 static bool usymtab_mustBreak (usymtab p_s);
 static bool usymtab_mustEscape (usymtab p_s);
 
@@ -182,7 +202,7 @@ static void clearFunctionTypes (void)
   uentryList_clear (functypes);
 }
 
-static /*@falsenull@*/ bool usymtab_isBranch (usymtab u)
+static /*@falsewhennull@*/ bool usymtab_isBranch (usymtab u)
 {
   return (usymtab_isDefined (u) && 
          (u->kind == US_TBRANCH || u->kind == US_FBRANCH
@@ -286,7 +306,8 @@ static /*@notnull@*/ /*@special@*/ usymtab
 
   t->mustBreak = FALSE;
   t->exitCode = XK_NEVERESCAPE;
-  
+
+  DPRINTF (("Create usymtab [%p]", t));
   return t;
 }
 
@@ -328,6 +349,14 @@ usymtab_initMod (void)
   oldtab = usymtab_undefined;
 }
 
+void 
+usymtab_destroyMod (void) /*@modifies utab, globtab, filetab@*/ /*@globals killed utab@*/ 
+{
+  DPRINTF (("Destroy usymtab [%p]: %d", utab, utab->nentries));
+  usymtab_freeAux (utab);
+  utab = usymtab_undefined;
+  /*@-globstate@*/ 
+} /*@=globstate@*/
 
 void
 usymtab_initGlobalMarker () /*@globals globtab@*/
@@ -352,12 +381,14 @@ usymtab_initGlobalMarker () /*@globals globtab@*/
 void
 usymtab_initBool ()
 {
+  DPRINTF (("Init bool!"));
+
   if (context_getFlag (FLG_NOLIB))
     {
       ctype boolt = ctype_bool;
       /* evs 2000-07-24: bool is now treated as abstract (always) */
 
-      uentry boolentry = uentry_makeBoolDatatype (YES);
+      uentry boolentry = uentry_makeBoolDatatype (qual_createAbstract ());
       usymtab_supGlobalEntry (boolentry);
       context_addBoolAccess ();
 
@@ -367,13 +398,14 @@ usymtab_initBool ()
       */
 
       usymtab_supGlobalEntry 
-       (uentry_makeConstantAux (context_getFalseName (), boolt, 
-                                fileloc_getBuiltin (), FALSE,
-                                multiVal_makeInt (0)));
+       (uentry_makeConstantValue (context_getFalseName (), boolt, 
+                                  fileloc_getBuiltin (), FALSE, 
+                                  multiVal_makeInt (0)));
+
       usymtab_supGlobalEntry 
-       (uentry_makeConstantAux (context_getTrueName (), boolt, 
-                                fileloc_getBuiltin (), FALSE,
-                                multiVal_makeInt (1)));
+       (uentry_makeConstantValue (context_getTrueName (), boolt, 
+                                  fileloc_getBuiltin (), FALSE, 
+                                  multiVal_makeInt (1)));
     }
 }
 
@@ -498,13 +530,14 @@ usymtab_addEntryBase (/*@notnull@*/ usymtab s, /*@only@*/ uentry e)
     }
   else
     {
-      int thisentry = s->nentries;  
+      usymId thisentry = usymId_fromInt (s->nentries); 
       
       if (uentry_isVar (e))
        {
-         uentry_setSref (e, sRef_makeCvar (globScope, thisentry, 
-                                           uentry_getType (e),
-                                           stateInfo_makeLoc (uentry_whereLast (e))));
+         uentry_setSref 
+           (e, sRef_makeCvar (globScope, thisentry, 
+                              uentry_getType (e),
+                              stateInfo_makeLoc (uentry_whereLast (e), SA_DECLARED)));
        }
       
       usymtab_addEntryQuiet (s, e);
@@ -524,7 +557,7 @@ usymtab_addEntryAlways (/*@notnull@*/ usymtab s, /*@only@*/ uentry e)
   */
 
   uentry old;
-  int thisentry = s->nentries;  
+  usymId thisentry = usymId_fromInt (s->nentries);
 
   if (uentry_isValid (old = usymtab_lookupQuiet (s, uentry_rawName (e))))
     {
@@ -542,9 +575,10 @@ usymtab_addEntryAlways (/*@notnull@*/ usymtab s, /*@only@*/ uentry e)
 
   if (uentry_isVar (e) && !uentry_isGlobalMarker (e))
     {
-      uentry_setSref (e, sRef_makeCvar (globScope, thisentry, 
-                                       uentry_getType (e),
-                                       stateInfo_makeLoc (uentry_whereLast (e))));
+      uentry_setSref 
+       (e, sRef_makeCvar (globScope, thisentry, 
+                          uentry_getType (e),
+                          stateInfo_makeLoc (uentry_whereLast (e), SA_DECLARED)));
     }
   
   usymtab_addEntryQuiet (s, e);
@@ -556,7 +590,7 @@ usymtab_addEntryAux (/*@notnull@*/ usymtab st, /*@keep@*/ uentry e, bool isSref)
      /*@globals globtab@*/
      /*@modifies st, e@*/
 {
-  usymId thisentry = st->nentries;
+  usymId thisentry = usymId_fromInt (st->nentries);
 
   llassert (!uentry_isElipsisMarker (e));
 
@@ -585,7 +619,8 @@ usymtab_addEntryAux (/*@notnull@*/ usymtab st, /*@keep@*/ uentry e, bool isSref)
 
       if (uentry_isStatic (e))
        {
-         sRef sr = sRef_makeCvar (st->lexlevel, thisentry, ct, stateInfo_makeLoc (uentry_whereLast (e)));
+         sRef sr = sRef_makeCvar (st->lexlevel, thisentry, ct,
+                                  stateInfo_makeLoc (uentry_whereLast (e), SA_DECLARED));
 
          if (sRef_isStack (sr) || sRef_isLocalState (sr))
            {
@@ -597,14 +632,15 @@ usymtab_addEntryAux (/*@notnull@*/ usymtab st, /*@keep@*/ uentry e, bool isSref)
        }
       else
        {
-         uentry_setSref (e, sRef_makeCvar (st->lexlevel, thisentry, ct, stateInfo_makeLoc (uentry_whereLast (e))));
+         uentry_setSref 
+           (e, sRef_makeCvar (st->lexlevel, thisentry, ct,
+                              stateInfo_makeLoc (uentry_whereLast (e), SA_DECLARED)));
        }
     }
 
   if (uentry_isDatatype (e))
     {
-      
-      uentry_setDatatype (e, thisentry);
+      uentry_setDatatype (e, typeId_fromUsymId (thisentry));
     }
 
   if (uentry_isFunction (e))
@@ -681,7 +717,7 @@ usymtab_supEntryAux (/*@notnull@*/ usymtab st,
 {
   cstring ename = uentry_rawName (e);
   bool staticEntry = FALSE;
-  int eindex;
+  usymId eindex;
 
   DPRINTF (("Sup entry aux: %s", uentry_unparseFull (e)));
   
@@ -691,7 +727,7 @@ usymtab_supEntryAux (/*@notnull@*/ usymtab st,
     {
       eindex = usymtab_getIndex (st, ename);
 
-      if (eindex != NOT_FOUND)
+      if (usymtab_indexFound (eindex))
        {
          uentry ce = st->entries[eindex];      
          
@@ -705,7 +741,7 @@ usymtab_supEntryAux (/*@notnull@*/ usymtab st,
              uentry_showWhereLast (ce);
            }
 
-         if (eindex == st->nentries - 1)
+         if (eindex == usymId_fromInt (st->nentries - 1))
            {
             ;
            }
@@ -746,11 +782,9 @@ usymtab_supEntryAux (/*@notnull@*/ usymtab st,
     }
   }
 
-  DPRINTF (("Using symtab: %s", usymtab_unparseLocalAux (st)));
-
   eindex = usymtab_getIndex (st, ename);
       
-  if (eindex != NOT_FOUND)
+  if (usymtab_indexFound (eindex))
     {
       uentry ce = st->entries[eindex];
       
@@ -777,7 +811,7 @@ usymtab_supEntryAux (/*@notnull@*/ usymtab st,
 
          if (uentry_isDatatype (e))
            {
-             uentry_setDatatype (e, eindex);
+             uentry_setDatatype (e, typeId_fromUsymId (eindex));
            }
          
          if (st == globtab && !uentry_isSpecified (e))
@@ -813,7 +847,7 @@ usymtab_supEntryAux (/*@notnull@*/ usymtab st,
                  st->entries[eindex] = e;
                  ce = e;
 
-                 if (uentry_isDatatype (e)) uentry_setDatatype (e, eindex);
+                 if (uentry_isDatatype (e)) uentry_setDatatype (e, typeId_fromUsymId (eindex));
                }
              else 
                {
@@ -830,7 +864,7 @@ usymtab_supEntryAux (/*@notnull@*/ usymtab st,
 
                      if (uentry_isDatatype (e)) 
                        {
-                         uentry_setDatatype (e, eindex);
+                         uentry_setDatatype (e, typeId_fromUsymId (eindex));
                        }
                      
                      if (cstringTable_isDefined (st->htable))
@@ -853,13 +887,21 @@ usymtab_supEntryAux (/*@notnull@*/ usymtab st,
 
              if (uentry_isDeclared (ce))
                {
-                 llassert ((st->lexlevel > fileScope || !sRef_modInFunction ()));
+                 /* evans 2001-08-26
+                   No - this can happen for internal typedefs
+                   llassert ((st->lexlevel > fileScope || !sRef_modInFunction ()));
+                 */
+
                  DPRINTF (("Merge defn"));
                  uentry_mergeDefinition (ce, e);
                }
              else 
                {
-                 llassert ((st->lexlevel > fileScope || !sRef_modInFunction ()));
+                 /* evans 2001-08-26
+                   No - this can happen for internal typedefs
+                   llassert ((st->lexlevel > fileScope || !sRef_modInFunction ()));
+                 */
+
                  DPRINTF (("Merge entries..."));
                  uentry_mergeEntries (ce, e);
                  DPRINTF (("After: %s", uentry_unparseFull (ce)));
@@ -871,7 +913,8 @@ usymtab_supEntryAux (/*@notnull@*/ usymtab st,
          if (!(st->lexlevel > fileScope || !sRef_modInFunction ()))
            {
              if (uentry_isDatatype (e) || uentry_isAnyTag (e)
-                 || uentry_isEnumConstant (e))
+                 || uentry_isEnumConstant (e)
+                 || uentry_isStatic (e)) /* bug fix from Brian St. Pierre */
                {
                  ; /* 
                     ** Not a bug.  Code like,
@@ -907,7 +950,9 @@ usymtab_supEntryAux (/*@notnull@*/ usymtab st,
              ct = ctype_getReturnType (ct);
            }
          
-         uentry_setSref (ce, sRef_makeCvar (st->lexlevel, eindex, ct, stateInfo_makeLoc (uentry_whereLast (ce))));
+         uentry_setSref
+           (ce, sRef_makeCvar (st->lexlevel, eindex, ct,
+                               stateInfo_makeLoc (uentry_whereLast (ce), SA_DECLARED)));
        }
     }
   else /* no previous entry */
@@ -929,7 +974,7 @@ usymtab_supEntryAux (/*@notnull@*/ usymtab st,
          
          eindex = usymtab_getIndex (filetab, ename);
          
-         if (eindex != NOT_FOUND)
+         if (usymtab_indexFound (eindex))
            {
              uentry ce = filetab->entries[eindex];
 
@@ -995,21 +1040,20 @@ usymtab_supEntryAux (/*@notnull@*/ usymtab st,
     }
 
  exitPoint:
-    return (staticEntry ? USYMIDINVALID : eindex);
+    return (staticEntry ? usymId_invalid : eindex);
 }
 
-# ifndef NOLCL
 static void
 usymtab_replaceEntryAux (/*@notnull@*/ usymtab st, /*@only@*/ uentry e)
    /*@globals globtab@*/ /*@modifies st, e@*/
 {
   cstring ename = uentry_rawName (e);
-  int eindex;
+  usymId eindex;
 
   /* static tags in global scope */
   eindex = usymtab_getIndex (st, ename);
   
-  if (eindex != NOT_FOUND)
+  if (usymtab_indexFound (eindex))
     {
       uentry ce = st->entries[eindex];      
       
@@ -1027,7 +1071,6 @@ usymtab_replaceEntryAux (/*@notnull@*/ usymtab st, /*@only@*/ uentry e)
       eindex = usymtab_addEntryAux (st, e, FALSE);
     }
 }
-# endif
 
 /*@=deparrays@*/ 
 
@@ -1121,13 +1164,14 @@ usymtab_supTypeEntry (/*@only@*/ uentry e)
 
   if (uentry_isAbstractDatatype (e))
     {
-      uid = usymtab_supAbstractTypeEntry (e, FALSE);
-      ret = ctype_createAbstract (uid);
+      typeId tid = usymtab_supAbstractTypeEntry (e, FALSE);
+      ret = ctype_createAbstract (tid);
+      uid = typeId_toUsymId (tid);
     }
   else
     {
       uid = usymtab_supEntryAux (globtab, e, FALSE);
-      ret = ctype_createUser (uid);
+      ret = ctype_createUser (typeId_fromUsymId (uid));
     }
 
   if (sRef_modInFunction ())
@@ -1149,7 +1193,7 @@ usymtab_supReturnTypeEntry (/*@only@*/ uentry e)
 
   if (uentry_isAbstractDatatype (e))
     {
-      uid = usymtab_supAbstractTypeEntry (e, FALSE);
+      uid = typeId_toUsymId (usymtab_supAbstractTypeEntry (e, FALSE));
     }
   else if (uentry_isMaybeAbstract (e) && context_getFlag (FLG_IMPABSTRACT))
     {
@@ -1182,14 +1226,15 @@ usymtab_supReturnTypeEntry (/*@only@*/ uentry e)
       if (maybeabs)
        {
          uentry ux;
-         uid = usymtab_supAbstractTypeEntry (e, FALSE);
-         ux = usymtab_getTypeEntry (uid);
+         typeId tid = usymtab_supAbstractTypeEntry (e, FALSE);
+         ux = usymtab_getTypeEntry (tid);
          uentry_setAbstract (ux);
+         uid = typeId_toUsymId (tid);
        }
       else
        {
          uid = usymtab_supEntryAux (globtab, e, FALSE);
-         e = usymtab_getTypeEntry (uid);
+         e = usymtab_getTypeEntry (typeId_fromUsymId (uid));
          
          if (uentry_isMaybeAbstract (e))
            {
@@ -1200,12 +1245,14 @@ usymtab_supReturnTypeEntry (/*@only@*/ uentry e)
   else
     {
       uid = usymtab_supEntryAux (globtab, e, FALSE);
-      e = usymtab_getTypeEntry (uid);
+      e = usymtab_getTypeEntry (typeId_fromUsymId (uid));
 
+      /*? evans 2002-12-16 removed this? it doesn't make sense
       if (uentry_isMaybeAbstract (e))
        {
          uentry_setConcrete (e);
        }
+      */
     }
   
   if (sRef_modInFunction ())
@@ -1216,15 +1263,15 @@ usymtab_supReturnTypeEntry (/*@only@*/ uentry e)
     return (globtab->entries[uid]);
 }
 
-usymId
+typeId
 usymtab_supAbstractTypeEntry (/*@only@*/ uentry e, bool dodef)
   /*@globals globtab, filetab@*/
   /*@modifies globtab, e@*/
 {
-  usymId uid;
+  typeId uid;
   uentry ue;
 
-  uid = usymtab_supEntryAux (globtab, e, FALSE);
+  uid = typeId_fromUsymId (usymtab_supEntryAux (globtab, e, FALSE));
   ue = usymtab_getTypeEntry (uid);
 
   if (dodef)
@@ -1245,15 +1292,14 @@ usymtab_supAbstractTypeEntry (/*@only@*/ uentry e, bool dodef)
   return (uid);
 }
 
-# ifndef NOLCL
-usymId
+typeId
 usymtab_supExposedTypeEntry (/*@only@*/ uentry e, bool dodef)
   /*@globals globtab, filetab@*/
   /*@modifies globtab, e@*/
 {
-  usymId uid;
+  typeId uid;
 
-  uid = usymtab_supEntryAux (globtab, e, FALSE);
+  uid = typeId_fromUsymId (usymtab_supEntryAux (globtab, e, FALSE));
 
   if (dodef)
     {
@@ -1267,16 +1313,15 @@ usymtab_supExposedTypeEntry (/*@only@*/ uentry e, bool dodef)
       recordFunctionType (globtab->entries[uid]);
     }
 
-  return (uid);
+  return uid;
 }
-# endif
 
 ctype
 usymtab_supForwardTypeEntry (/*@only@*/ uentry e)
   /*@globals globtab, filetab@*/
   /*@modifies globtab, e@*/
 {
-  usymId uid = usymtab_supEntryAux (globtab, e, FALSE);
+  typeId uid = typeId_fromUsymId (usymtab_supEntryAux (globtab, e, FALSE));
   uentry ue = usymtab_getTypeEntry (uid);
 
     uentry_setDatatype (ue, uid);
@@ -1295,7 +1340,6 @@ void
   /*@modifies utab, globtab, e@*/
 {
   sRef old = uentry_getSref (e);
-
   
   if (sRef_isType (old))
     {
@@ -1357,7 +1401,7 @@ usymtab_inDeepScope () /*@globals utab@*/
   return (utab->lexlevel > paramsScope);
 }
 
-static int
+static usymId
 usymtab_getIndex (/*@notnull@*/ usymtab s, cstring k)
 {
   int i;
@@ -1367,7 +1411,7 @@ usymtab_getIndex (/*@notnull@*/ usymtab s, cstring k)
   if (cstringTable_isDefined (s->htable))
     {
       i = cstringTable_lookup (s->htable, k);
-      return i;
+      return usymId_fromInt (i);
     }
   else
     {
@@ -1380,33 +1424,37 @@ usymtab_getIndex (/*@notnull@*/ usymtab s, cstring k)
          if (!uentry_isUndefined (current) 
              && cstring_equal (uentry_rawName (current), k))
            {
-             return i;
+             return usymId_fromInt (i);
            }
        }
 
-      return NOT_FOUND;
+      return usymId_notfound;
     }
 }
 
 static uentry
-usymtab_fetchIndex (/*@notnull@*/ usymtab s, int i)
+usymtab_fetchIndex (/*@notnull@*/ usymtab s, usymId ui)
 {
+  int i = usymId_toInt (ui);
   llassert (i >= 0 && i < s->nentries);
   return (s->entries[i]);
 }
 
-usymId
+typeId
 usymtab_getTypeId (cstring k) /*@globals globtab@*/
 {
   usymId uid = usymtab_getIndex (globtab, k);
 
-  if (uid == NOT_FOUND) return USYMIDINVALID;
-
-  if (!(uentry_isDatatype (usymtab_getTypeEntry (uid)))) {
-    return USYMIDINVALID;
-  }
-
-  return uid;
+  if (!usymtab_indexFound (uid)
+      || !(uentry_isDatatype (usymtab_getTypeEntry (typeId_fromUsymId (uid)))))
+    
+    {
+      return typeId_invalid;
+    }
+  else
+    {
+      return typeId_fromUsymId (uid);
+    }
 }
 
 /*@dependent@*/ uentry
@@ -1445,16 +1493,16 @@ usymtab_getId (cstring k) /*@globals globtab@*/
   usymId uid = usymtab_getIndex (globtab, k);
   uentry ue;
 
-  if (uid == NOT_FOUND)
+  if (!usymtab_indexFound (uid))
     {
-      return USYMIDINVALID;
+      return usymId_invalid;
     }
 
   ue = usymtab_getGlobalEntry (uid);
 
   if (uentry_isPriv (ue))
     {
-      return USYMIDINVALID;
+      return usymId_invalid;
     }
 
   return uid;
@@ -1463,9 +1511,9 @@ usymtab_getId (cstring k) /*@globals globtab@*/
 static /*@exposed@*/ uentry 
 usymtab_getEntryAux (/*@notnull@*/ usymtab s, usymId uid)
 {
-  llassert (uid != USYMIDINVALID);
+  llassert (uid != usymId_invalid);
  
-  if (uid < 0 || uid >= s->nentries)
+  if (uid < 0 || uid >= usymId_fromInt (s->nentries))
     {
       llcontbug (message ("usymtab_getEntry: out of range: level = %d [%d]",
                          s->lexlevel, uid));
@@ -1495,13 +1543,12 @@ usymtab_getEntryAux (/*@notnull@*/ usymtab s, usymId uid)
     }
 }
 
-/*@dependent@*/ /*@exposed@*/ uentry 
-  usymtab_getTypeEntry (usymId uid)
+/*@dependent@*/ /*@exposed@*/ uentry usymtab_getTypeEntry (typeId uid)
   /*@globals globtab@*/
 {
   if (dbgload)
     {
-      if (uid >= 0 && uid < globtab->nentries)
+      if (uid >= 0 && uid < typeId_fromInt (globtab->nentries))
        {
          return (globtab->entries[uid]);
        }
@@ -1512,7 +1559,7 @@ usymtab_getEntryAux (/*@notnull@*/ usymtab s, usymId uid)
     }
   else
     {
-      llassert (uid >= 0 && uid < globtab->nentries);      
+      llassert (uid >= 0 && uid < typeId_fromInt (globtab->nentries));
       return (globtab->entries[uid]);
     }
 }
@@ -1521,30 +1568,27 @@ usymtab_getEntryAux (/*@notnull@*/ usymtab s, usymId uid)
 ** in load files
 */
 
-/*@dependent@*/ /*@exposed@*/ uentry 
-  usymtab_getTypeEntrySafe (usymId uid)
+/*@dependent@*/ /*@exposed@*/ uentry usymtab_getTypeEntrySafe (typeId uid)
   /*@globals globtab@*/
 {
-  if (uid < 0 || uid >= globtab->nentries)
+  if (uid < 0 || uid >= typeId_fromInt (globtab->nentries))
     {
       return uentry_undefined;
     }
-
-      return (globtab->entries[uid]);
+  
+  return (globtab->entries[uid]);
 }
 
-bool
-  usymtab_isBoolType (usymId uid)
+bool usymtab_isBoolType (typeId uid)
   /*@globals globtab@*/
 {
-  llassert (uid >= 0 && uid < globtab->nentries);
+  llassert (uid >= 0 && uid < typeId_fromInt (globtab->nentries));
 
   return (cstring_equal (uentry_rawName (globtab->entries[uid]),
                         context_getBoolName ()));
 }
  
-cstring
-usymtab_getTypeEntryName (usymId uid)
+cstring usymtab_getTypeEntryName (typeId uid)
    /*@globals globtab@*/
 {
   uentry ue;
@@ -1566,6 +1610,7 @@ usymtab_getTypeEntryName (usymId uid)
   return (uentry_getName (ue));
 }
 
+# if 0
 /*@unused@*/ static void
 usymtab_rehash (/*@notnull@*/ usymtab s)
 {
@@ -1576,13 +1621,14 @@ usymtab_rehash (/*@notnull@*/ usymtab s)
       cstringTable_free (s->htable);
     }
   
-  s->htable = cstringTable_create (LLHASHSIZE);
+  s->htable = cstringTable_create (LLAHSHSIZE);
 
   for (i = 0; i < s->nentries; i++)
     {
       cstringTable_insert (s->htable, cstring_copy (uentry_rawName (s->entries[i])), i);
     }
 }
+# endif
 
 /*
 ** superficial copy of usymtab
@@ -1613,12 +1659,16 @@ usymtab_shallowFree (/*@only@*/ /*@notnull@*/ usymtab s)
   /*@-compdestroy@*/ sfree (s); /*@=compdestroy@*/
 }
 
+usymId usymtab_convertTypeId (typeId uid)
+{
+  return usymtab_convertId (typeId_toUsymId (uid));
+}
+
 /*
-** converts usymId from old table to sorted one
+** usymtab_convertId: converts usymId from old table to sorted one
 */
 
-usymId 
-  usymtab_convertId (usymId uid)
+usymId usymtab_convertId (usymId uid)
   /*@globals oldtab, utab@*/
 {
   uentry ue;
@@ -1639,7 +1689,7 @@ usymId
            uentry_unparse (ue), uid,
            uentry_unparse (utab->entries[ret]), ret));
 
-  llassertprint (ret != USYMIDINVALID, ("convertId: return is invalid"));
+  llassertprint (ret != usymId_invalid, ("convertId: return is invalid"));
 
   return (ret);
 }
@@ -1779,6 +1829,17 @@ void usymtab_dump (FILE *fout)
   lastekind = KINVALID;
 
   fprintf(fout, ";; Library constraints\n");
+
+ /*drl July 27 added this so that libraries without
+    buffer constraints would be handled correctly.
+    I'm trying to do this without breaking older libraries.
+
+    Splint should still be able to handle libraries without this message.
+ */
+
+  
+  fprintf(fout, "start_Buffer_Constraints\n");
+
   for (i = 0; i < utab->nentries; i++)
     {
       uentry thisentry = utab->entries[i];
@@ -1821,11 +1882,9 @@ void usymtab_dump (FILE *fout)
                  
        }
     }
-    
-
-  
 }
 
+
 void usymtab_load (FILE *f)
   /*@globals utab, globtab@*/
   /*@modifies utab, *f@*/
@@ -1877,7 +1936,7 @@ void usymtab_load (FILE *f)
        {
          llfatalerror
            (cstring_makeLiteral 
-            ("Library is in obsolete format.  Use lclint +whichlib "
+            ("Library is in obsolete format.  Use splint +whichlib "
              "to see which library is being loaded."));
        }
 
@@ -1899,6 +1958,30 @@ void usymtab_load (FILE *f)
        {       
          int lastindex = utab->nentries;
          ue = usymtab_addEntryAlways (utab, ue);
+
+
+# if 0
+         if (uentry_isConstant (ue)) /*@i23! isPreProcessorMacro */
+           {
+             cstring uname = uentry_getName (ue);
+             
+             /* Also check its a macro... */
+             DPRINTF (("Installing: %s", uname));
+
+             cpphash_installMacro 
+               (mstring_copy (cstring_toCharsSafe (uname)),
+                cstring_length (uname),
+                cpplib_createDefinition (message ("%s 255", uname),
+                                         loc,
+                                         FALSE, FALSE).defn,
+                cpphash_hashCode (cstring_toCharsSafe (uname),
+                                  cstring_length (uname),
+                                  CPP_HASHSIZE));
+             
+             DPRINTF (("After install: %s", uname));
+           }
+# endif
+
          if (utab->nentries != lastindex + 1)
            {
              DPRINTF (("No add: %s", uentry_unparseFull (ue)));
@@ -1948,17 +2031,27 @@ void usymtab_load (FILE *f)
     {
       ; /* ignore ;-comments */
     }
+
+  /*drl July 27 added this so that libraries without
+    buffer constraints would be handled correctly.
+    I'm trying to do this without breaking older libraries*/
+  
+  /*check for "optional" start buffer constraints message*/
+
+  if (mstring_equalPrefix (s, "start_Buffer_Constraints")) 
+    {
+      (void) fgets (s, MAX_DUMP_LINE_LENGTH, f);
+    }
   
   while (s != NULL && *s != ';')
     {
       constraintList preconditions;
       constraintList postconditions;
-
-      cstring name = cstring_fromChars(reader_getWord(&s) );
+      cstring name = cstring_fromChars (reader_getWord (&s));
       cstring temp;
-      ue = usymtab_lookup ( name );
 
-      cstring_free(name);
+      ue = usymtab_lookup (name);
+      cstring_free (name);
       
       preconditions = constraintList_undefined;
       postconditions = constraintList_undefined;
@@ -2026,8 +2119,8 @@ usymtab_enterFile ()
     {
       if (sRef_hasDerived (uentry_getSref (ue)))
        {
-         fprintf (g_msgstream, "Derived Global: %s\n", uentry_unparse (ue));
-         fprintf (g_msgstream, "sRef: %s\n", sRef_unparseFull (ue->sref));
+         fprintf (g_warningstream, "Derived Global: %s\n", uentry_unparse (ue));
+         fprintf (g_warningstream, "sRef: %s\n", sRef_unparseFull (ue->sref));
        }
     } end_usymtab_entries ;
 
@@ -2118,7 +2211,10 @@ usymtab_handleParams (void)
                {
                  if (sRef_isStateSpecial (pref))
                    {
-                     uentry_setDefState (ue, SS_ALLOCATED);
+                     uentry_setDefState (ue, SS_SPECIAL); /* ALLOCATED); */
+                     /* evans 2002-01-01: should be unnecessary, the pre clauses
+                     **    set the state if necessary.
+                     */
                    }
                  else
                    {
@@ -2282,6 +2378,8 @@ usymtab_enterFunctionScope (uentry fcn)
 {
   usymtab t = usymtab_create (US_NORMAL, utab, TRUE);
 
+  DPRINTF (("Enter function: %s", uentry_unparse (fcn)));
+
   if (utab->lexlevel != fileScope)
     {
       if (utab->lexlevel > fileScope)
@@ -2311,7 +2409,7 @@ usymtab_enterFunctionScope (uentry fcn)
       
       if (sRef_isUndefGlob (el))
        {
-         int index = sRef_getScopeIndex (el);
+         usymId index = sRef_getScopeIndex (el);
          sRef sr = sRef_updateSref (el);
          fileloc loc = uentry_whereEarliest (fcn);
        
@@ -2379,6 +2477,9 @@ usymtab_enterFunctionScope (uentry fcn)
     } end_globSet_allElements;
 
   DPRINTF (("Globs after: %s", globSet_unparse (uentry_getGlobs (fcn))));
+# ifdef DEBUGSPLINT
+  usymtab_checkAllValid ();
+# endif
 }
 
 static void
@@ -2539,6 +2640,8 @@ usymtab_newCase (/*@unused@*/ exprNode pred, exprNode last)
   bool mustReturn = usymtab_mustEscape (utab);
   usymtab stab = utab;
 
+  DPRINTF (("New case!"));
+
   /*
   ** Find last case (or outer switch)
   */
@@ -2548,9 +2651,7 @@ usymtab_newCase (/*@unused@*/ exprNode pred, exprNode last)
       stab = stab->env;
       llassert (stab != GLOBAL_ENV);
     }
-
-  /* ??? */
-
+  
   while (stab->kind == US_CBRANCH)
     {
       stab = stab->env;
@@ -2648,6 +2749,10 @@ usymtab_popAndBranch (exprNode pred, /*@unused@*/ exprNode expr)
        }
     }
 
+  DPRINTF (("Popping and: %s / %s",
+           guardSet_unparse (utab->guards),
+           guardSet_unparse (exprNode_getGuards (pred))));
+
   utab->guards = guardSet_levelUnionFree (utab->guards, 
                                          guardSet_invert (exprNode_getGuards (pred)), 
                                          utab->lexlevel);
@@ -2753,7 +2858,7 @@ usymtab_exitSwitch (/*@unused@*/ exprNode sw, bool allpaths)
            {
              usymtab_entries (stab, current)
                {
-                 if (usymtab_getIndex (ttab, uentry_rawName (current)) == NOT_FOUND)
+                 if (!usymtab_indexFound (usymtab_getIndex (ttab, uentry_rawName (current))))
                    {
                      uentry old = /*@-compmempass@*/
                        usymtab_lookupAux (ltab, uentry_rawName (current));
@@ -2860,13 +2965,17 @@ updateNullState (sRef el, /*@notnull@*/ usymtab ttab,
              if (!guardSet_isGuarded (ttab->guards, el) 
                  && !sRef_isNotNull (sr))
                {
+                 DPRINTF (("Here! %s / %s",
+                           sRef_unparseFull (sr),
+                           sRef_unparseFull (el)));
                  sRef_setDerivNullState (sr, el, NS_DEFNULL);
-                               }
+               }
            }
        }
       else
        {
-               }
+         ;
+       }
       
       ue = usymtab_getRefTab (ftab, level, index);
       
@@ -2874,7 +2983,6 @@ updateNullState (sRef el, /*@notnull@*/ usymtab ttab,
        {
          sRef sr = uentry_getSref (ue);
          
-         
          if (!trueGuard) /* yikes!  forgot the ! */
            {
              sRef_setDerivNullState (sr, el, NS_NOTNULL);
@@ -2886,7 +2994,7 @@ updateNullState (sRef el, /*@notnull@*/ usymtab ttab,
                  && !sRef_isNotNull (sr))
                {
                  sRef_setDerivNullState (sr, el, NS_DEFNULL);
-                               }
+               }
            }
        }
       else
@@ -2970,7 +3078,7 @@ usymtab_popBranches (exprNode pred, exprNode tbranch, exprNode fbranch,
     {
       uentry fthis = ftab->entries[i];
       uentry old = usymtab_lookupAux (env, uentry_rawName (fthis));
-      int    tindex = usymtab_getIndex (ttab, uentry_rawName (fthis));
+      usymId tindex = usymtab_getIndex (ttab, uentry_rawName (fthis));
       
       DPRINTF (("Entry: %s / %s", uentry_unparseFull (fthis), uentry_unparseFull (old)));
          
@@ -2981,7 +3089,7 @@ usymtab_popBranches (exprNode pred, exprNode tbranch, exprNode fbranch,
          continue;
        }
       
-      if (tindex != NOT_FOUND)
+      if (usymtab_indexFound (tindex))
        {
          uentry tthis = ttab->entries[tindex];
 
@@ -3648,6 +3756,8 @@ checkGlobalReturn (uentry glob, sRef orig)
          else
            {
              ctype ct = ctype_realType (uentry_getType (glob));
+             
+             DPRINTF (("Check global destroyed: %s", uentry_unparseFull (glob)));
 
              if (ctype_isVisiblySharable (ct))
                {
@@ -3665,7 +3775,7 @@ checkGlobalReturn (uentry glob, sRef orig)
              else
                {
                  sRef_protectDerivs ();
-                 (void) checkGlobalDestroyed (sr, g_currentloc);
+                 (void) transferChecks_globalDestroyed (sr, g_currentloc);
                  sRef_clearProtectDerivs ();
                }
            }
@@ -3708,6 +3818,10 @@ checkGlobalReturn (uentry glob, sRef orig)
                    }
                }
              
+             DPRINTF (("Here: %s / %s",
+                       uentry_unparseFull (glob),
+                       sRef_unparseFull (sr)));
+
              if (ctype_isRealPointer (uentry_getType (glob))
                  && sRef_possiblyNull (sr)
                  && !uentry_possiblyNull (glob))
@@ -3724,7 +3838,8 @@ checkGlobalReturn (uentry glob, sRef orig)
                }
              else
                {
-                 checkGlobReturn (glob);
+                 DPRINTF (("Check transfer: %s", uentry_unparseFull (glob)));
+                 transferChecks_globalReturn (glob);
                }
            }
        }
@@ -3738,9 +3853,7 @@ checkGlobalReturn (uentry glob, sRef orig)
 void usymtab_checkFinalScope (bool isReturn)
   /*@globals utab@*/
 {
-  bool mustFree = context_getFlag (FLG_MUSTFREE);
   bool mustDefine = context_getFlag (FLG_MUSTDEFINE);
-  /* bool mustNotAlias = context_getFlag (FLG_MUSTNOTALIAS); */
   sRefSet checked = sRefSet_new ();
   usymtab stab = utab;
   int i;
@@ -3768,13 +3881,11 @@ void usymtab_checkFinalScope (bool isReturn)
 
              if (!uentry_sameObject (ce, oue))
                {
-                 DPRINTF (("Skipping outer entry: %s / %s", uentry_unparseFull (ce),
-                           uentry_unparseFull (oue)));
-                 /*@i32  what if it is one an alternate branch? */
+                 /* what if it is one an alternate branch? */
                  /*@innercontinue@*/ continue;
                }
            }
-                           
+         
          DPRINTF (("Here check final scope: %s", uentry_unparseFull (ce)));
          
          if (ctype_isFunction (uentry_getType (ce)))
@@ -3787,6 +3898,7 @@ void usymtab_checkFinalScope (bool isReturn)
              || sRef_isFileOrGlobalScope (rb))
            {
              /* Don't do the loseref check...but should check state! */
+             DPRINTF (("Skipping check 1"));
            }
          else if (sRef_isDefinitelyNull (sr)
                   || usymtab_isDefinitelyNull (sr))
@@ -3794,6 +3906,8 @@ void usymtab_checkFinalScope (bool isReturn)
              /*
              ** No state reference errors for definitely null references.
              */
+
+             DPRINTF (("Skipping check 2"));
            }
          else
            {
@@ -3813,7 +3927,7 @@ void usymtab_checkFinalScope (bool isReturn)
                if (stateValue_isError (fval)
                    || sRef_isStateUndefined (sr)) /* No errors for undefined state */
                  {
-                   ;
+                   DPRINTF (("Skipping check 3"));
                  }
                else 
                  {
@@ -3829,12 +3943,6 @@ void usymtab_checkFinalScope (bool isReturn)
                    
                    if (cstring_isDefined (msg)) 
                      {
-                       /*@i32 print extra info for assignments@*/
-                       DPRINTF (("From: %s", sRef_unparseFull (sr)));
-                       DPRINTF (("Null? %s / %s",
-                                 bool_unparse (sRef_isDefinitelyNull (sr)),
-                                 bool_unparse (usymtab_isGuarded (sr))));
-                       
                        if (optgenerror 
                            (FLG_STATETRANSFER,
                             message
@@ -3856,185 +3964,178 @@ void usymtab_checkFinalScope (bool isReturn)
              } end_valueTable_elements;
            }
 
-         if (mustFree)
+         DPRINTF (("Check mustfree entry: %s", uentry_unparseFull (ce)));
+         
+         if (!sRefSet_member (checked, sr) && !sRef_isFileOrGlobalScope (rb))
            {
-             DPRINTF (("Check entry: %s", uentry_unparseFull (ce)));
-             
-             if (!sRefSet_member (checked, sr) && !sRef_isFileOrGlobalScope (rb))
+             if (ctype_isRealSU (uentry_getType (ce))
+                 && !uentry_isAnyParam (ce)
+                 && !uentry_isRefParam (ce)
+                 && !uentry_isStatic (ce)
+                 && !sRef_isDependent (sr)
+                 && !sRef_isOwned (sr))
                {
-                 if (ctype_isRealSU (uentry_getType (ce))
-                     && !uentry_isAnyParam (ce)
-                     && !uentry_isRefParam (ce)
-                     && !uentry_isStatic (ce)
-                     && !sRef_isDependent (sr)
-                     && !sRef_isOwned (sr))
+                 sRefSet als = usymtab_allAliases (sr);
+                 
+                 if (sRefSet_isEmpty (als))
                    {
-                     sRefSet als = usymtab_allAliases (sr);
-                     
-                     if (sRefSet_isEmpty (als))
-                       {
-                         checkLocalDestroyed (sr, g_currentloc);
-                       }
-                     else
-                       {
-                         /* aliased, no problem */ ;
-                       }
-
-                     sRefSet_free (als);
+                     transferChecks_localDestroyed (sr, g_currentloc);
                    }
-                 else if
-                   (!uentry_isStatic (ce)
-                    && ((sRef_isNewRef (sr))
-                        || (((sRef_isOnly (sr) || sRef_isFresh (sr) 
-                              || sRef_isKeep (sr) || sRef_isOwned (sr))
-                             && !sRef_isDead (sr))
-                            && (!sRef_definitelyNull (sr))
-                            && (!usymtab_isDefinitelyNull (sr)))))
-                     {
-                       bool hasError = TRUE;
-                       
-                       DPRINTF (("Checking: %s", sRef_unparseFull (sr)));
-
-                       /*
-                       ** If its a scope exit, check if there is an alias.
-                       ** If so, make it only.  If not, there is an error.
-                       */
-                       
-                       if (!isReturn)
-                         {
-                           if (canLoseReference (sr, g_currentloc))
-                             {
-                               DPRINTF (("Can lose!"));
-                               hasError = FALSE;
-                             }
-                         }
-                       
-                       if (hasError)
-                         {
-                           if (sRef_hasLastReference (sr))
-                             {
-                               sRef ar = sRef_getAliasInfoRef (sr);
-                               
-                               if (optgenerror 
-                                   (FLG_MUSTFREE,
-                                    message
-                                    ("Last reference %q to %s storage %qnot %q before %q",
-                                     sRef_unparse (sr),
-                                     alkind_unparse (sRef_getAliasKind (sr)),
-                                     sRef_unparseOpt (ar),
-                                     cstring_makeLiteral (sRef_isKeep (sr) 
-                                                          ? "transferred" : "released"),
-                                     cstring_makeLiteral (isReturn 
-                                                          ? "return" : "scope exit")),
-                                    g_currentloc))
-                                 {
-                                   sRef_showRefLost (sr);
-                                 }
-                             }
-                           else if (sRef_isNewRef (sr))
-                             {
-                               if (optgenerror
-                                   (FLG_MUSTFREE,
-                                    message 
-                                    ("%q %q not released before %q",
-                                     cstring_makeLiteral 
-                                     (alkind_isKillRef (sRef_getOrigAliasKind (sr))
-                                      ? "Kill reference parameter" : "New reference"),
-                                     uentry_getName (ce),
-                                     cstring_makeLiteral (isReturn
-                                                          ? "return" : "scope exit")),
-                                    g_currentloc))
-                                 {
-                                   sRef_showAliasInfo (sr);
-                                 }
-                             }
-                           else 
-                             {
-                               if (ctype_isRealSU (sRef_getType (sr)))
-                                 {
-                                   checkStructDestroyed (sr, g_currentloc);
-                                 }
-                               else
-                                 {
-                                   DPRINTF (("Here we are: %s", sRef_unparseFull (sr)));
-
-                                   if (optgenerror
-                                       (FLG_MUSTFREE,
-                                        message 
-                                        ("%s storage %q not %q before %q",
-                                         alkind_capName (sRef_getAliasKind (sr)),
-                                         uentry_getName (ce),
-                                         cstring_makeLiteral (sRef_isKeep (sr) 
-                                                              ? "transferred" : "released"),
-                                         cstring_makeLiteral (isReturn 
-                                                              ? "return" : "scope exit")),
-                                        g_currentloc))
-                                     {
-                                       sRef_showAliasInfo (sr);
-                                       DPRINTF (("Storage: %s", sRef_unparseFull (sr)));
-                                     }
-                                 }
-                             }
-                         }
-                     }
                  else
                    {
-                     ;
+                     /* aliased, no problem */ ;
                    }
+                 
+                 sRefSet_free (als);
                }
-             else if (mustDefine && uentry_isOut (ce))
+             else if
+               (!uentry_isStatic (ce)
+                && ((sRef_isNewRef (sr))
+                    || (((sRef_isOnly (sr) || sRef_isFresh (sr) 
+                          || sRef_isKeep (sr) || sRef_isOwned (sr))
+                         && !sRef_isDead (sr))
+                        && (!sRef_definitelyNull (sr))
+                        && (!usymtab_isDefinitelyNull (sr)))))
                {
-                 if (!ynm_toBoolStrict (sRef_isReadable (sr)))
+                 bool hasError = TRUE;
+                 
+                 DPRINTF (("Checking: %s", sRef_unparseFull (sr)));
+                 
+                 /*
+                 ** If its a scope exit, check if there is an alias.
+                 ** If so, make it only.  If not, there is an error.
+                 */
+                 
+                 if (!isReturn)
                    {
-                     voptgenerror 
-                       (FLG_MUSTDEFINE,
-                        message ("Out storage %q not defined before %q",
-                                 uentry_getName (ce),
-                                 cstring_makeLiteral 
-                                 (isReturn ? "return" : "scope exit")),
-                        g_currentloc);
-                     
-                     /* uentry_showWhereDeclared (ce); */
+                     if (transferChecks_canLoseReference (sr, g_currentloc))
+                       {
+                         DPRINTF (("Can lose!"));
+                         hasError = FALSE;
+                       }
+                   }
+                 
+                 if (hasError)
+                   {
+                     if (sRef_hasLastReference (sr))
+                       {
+                         sRef ar = sRef_getAliasInfoRef (sr);
+                         
+                         if (optgenerror 
+                             (sRef_isFresh (ar) ? FLG_MUSTFREEFRESH : FLG_MUSTFREEONLY,
+                              message
+                              ("Last reference %q to %s storage %qnot %q before %q",
+                               sRef_unparse (sr),
+                               alkind_unparse (sRef_getAliasKind (sr)),
+                               sRef_unparseOpt (ar),
+                               cstring_makeLiteral (sRef_isKeep (sr) 
+                                                    ? "transferred" : "released"),
+                               cstring_makeLiteral (isReturn 
+                                                    ? "return" : "scope exit")),
+                              g_currentloc))
+                           {
+                             sRef_showRefLost (sr);
+                           }
+                       }
+                     else if (sRef_isNewRef (sr))
+                       {
+                         if (optgenerror
+                             (sRef_isFresh (sr) ? FLG_MUSTFREEFRESH : FLG_MUSTFREEONLY,
+                              message 
+                              ("%q %q not released before %q",
+                               cstring_makeLiteral 
+                               (alkind_isKillRef (sRef_getOrigAliasKind (sr))
+                                ? "Kill reference parameter" : "New reference"),
+                               uentry_getName (ce),
+                               cstring_makeLiteral (isReturn
+                                                    ? "return" : "scope exit")),
+                              g_currentloc))
+                           {
+                             sRef_showAliasInfo (sr);
+                           }
+                       }
+                     else 
+                       {
+                         if (ctype_isRealSU (sRef_getType (sr)))
+                           {
+                             transferChecks_structDestroyed (sr, g_currentloc);
+                           }
+                         else
+                           {
+                             if (optgenerror
+                                 (sRef_isFresh (sr) ? FLG_MUSTFREEFRESH : FLG_MUSTFREEONLY,
+                                  message 
+                                  ("%s storage %q not %q before %q",
+                                   alkind_capName (sRef_getAliasKind (sr)),
+                                   uentry_getName (ce),
+                                   cstring_makeLiteral (sRef_isKeep (sr) 
+                                                        ? "transferred" : "released"),
+                                   cstring_makeLiteral (isReturn 
+                                                        ? "return" : "scope exit")),
+                                  g_currentloc))
+                               {
+                                 sRef_showAliasInfo (sr);
+                                 DPRINTF (("Storage: %s", sRef_unparseFull (sr)));
+                               }
+                           }
+                       }
                    }
                }
              else
                {
-                 ; 
+                 ;
                }
+           }
+
+         if (mustDefine && uentry_isOut (ce))
+           {
+             /* No error if its dead (either only or error already reported */
+             if (!sRef_isReallyDefined (sr) && !sRef_isDead (sr))
+               {
+                 voptgenerror 
+                   (FLG_MUSTDEFINE,
+                    message ("Out storage %q not defined before %q",
+                             uentry_getName (ce),
+                             cstring_makeLiteral 
+                             (isReturn ? "return" : "scope exit")),
+                    g_currentloc);
+
+                 DPRINTF (("sr: %s", sRef_unparseFull (sr)));
+               }
+           }
+         
+         /*
+         ** also check state is okay
+         */
+         
+         if (usymtab_lexicalLevel () > functionScope
+             && uentry_isVariable (ce)
+             && (sRef_isLocalVar (sr)
+                 && (sRef_isDependent (sr) || sRef_isLocalState (sr))))
+           {
+             sRefSet ab = usymtab_aliasedBy (sr);
              
-             /*
-             ** also check state is okay
-             */
+             /* should do something more efficient here */
              
-             if (usymtab_lexicalLevel () > functionScope
-                 && uentry_isVariable (ce)
-                 && (sRef_isLocalVar (sr)
-                     && (sRef_isDependent (sr) || sRef_isLocalState (sr))))
+             if (sRefSet_isEmpty (ab))
                {
-                 sRefSet ab = usymtab_aliasedBy (sr);
-
-                 /* should do something more efficient here */
-
-                 if (sRefSet_isEmpty (ab))
-                   {
-                     /* and no local ref */
-                     DPRINTF (("Check lose ref: %s", uentry_unparseFull (ce)));
-                     checkLoseRef (ce);
-                   }
-                 else
-                   {
-                     ;
-                   }
-                 
-                 sRefSet_free (ab);
+                 /* and no local ref */
+                 DPRINTF (("Check lose ref: %s", uentry_unparseFull (ce)));
+                 transferChecks_loseReference (ce);
                }
-             else 
+             else
                {
                  ;
                }
              
-             checked = sRefSet_insert (checked, sr);
+             sRefSet_free (ab);
            }
+         else 
+           {
+             ;
+           }
+         
+         checked = sRefSet_insert (checked, sr);
        }
 
       llassert (usymtab_isDefined (stab->env));
@@ -4178,7 +4279,7 @@ void usymtab_checkFinalScope (bool isReturn)
                                        {
                                          ss (sr);
                                        }
-
+                                     
                                      DPRINTF (("Storage: %s", sRef_unparseFull (sr)));
                                    }  
                                }
@@ -4210,7 +4311,7 @@ void usymtab_checkFinalScope (bool isReturn)
                {
                  uentry param = usymtab_lookupQuiet (utab, uentry_rawName (arg));
                  DPRINTF (("Check param return: %s", uentry_unparseFull (param)));
-                 checkParamReturn (param);
+                 transferChecks_paramReturn (param);
                }
            }
        } end_uentryList_elements;
@@ -4255,6 +4356,8 @@ usymtab_quietExitScope (fileloc loc)
 {
   usymtab t = utab->env;
 
+  DPRINTF (("Quiet exit scope [%p]", utab));
+
   if (utab->reftable != NULL)
     {
       int i;
@@ -4281,9 +4384,14 @@ usymtab_quietExitScope (fileloc loc)
   t->mustBreak = utab->mustBreak;
   t->exitCode = utab->exitCode;
 
+  DPRINTF (("Free level [%p]", utab));
   usymtab_freeLevel (utab);
 
   utab = t;
+
+# ifdef DEBUGSPLINT
+  usymtab_checkAllValid ();
+# endif
 }
 
 /*
@@ -4311,7 +4419,7 @@ void usymtab_exitScope (exprNode expr)
   usymtab lctab = usymtab_undefined;
   bool mustReturn = exprNode_mustEscape (expr);
 
-  DPRINTF (("Exit scope"));
+  DPRINTF (("Exit scope [%p]", utab));
 
   if (utab->kind == US_CBRANCH)
     {
@@ -4330,32 +4438,34 @@ void usymtab_exitScope (exprNode expr)
     }
   
   if (utab->kind == US_TBRANCH || utab->kind == US_FBRANCH
-      || utab->kind == US_CBRANCH || utab->kind == US_SWITCH) {
-   
-    if (context_inMacro ()) {
-      /* evs 2000-07-25 */
-      /* Unparseable macro may end inside nested scope.  Deal with it. */
-      
-      llerror (FLG_SYNTAX, 
-              message ("Problem parsing macro body of %s (unbalanced scopes). "
-                       "Attempting to recover, recommend /*@notfunction@*/ before "
-                       "macro definition.", 
-                       context_inFunctionName ()));
-      
-      while (utab->kind == US_TBRANCH
-            || utab->kind == US_FBRANCH
-            || utab->kind == US_CBRANCH
-            || utab->kind == US_SWITCH) 
+      || utab->kind == US_CBRANCH || utab->kind == US_SWITCH) 
+    {
+      if (context_inMacro ()) 
        {
-         utab = utab->env;
-         llassert (utab != GLOBAL_ENV);
-       }
-    } else {
-      llcontbug (message ("exitScope: in branch: %q", usymtab_unparseStack ()));
-      /*@-branchstate@*/ 
-    } /*@=branchstate@*/
-  }
-
+         /* evs 2000-07-25 */
+         /* Unparseable macro may end inside nested scope.  Deal with it. */
+         
+         llerror (FLG_SYNTAX, 
+                  message ("Problem parsing macro body of %s (unbalanced scopes). "
+                           "Attempting to recover, recommend /*@notfunction@*/ before "
+                           "macro definition.", 
+                           context_inFunctionName ()));
+         
+         while (utab->kind == US_TBRANCH
+                || utab->kind == US_FBRANCH
+                || utab->kind == US_CBRANCH
+                || utab->kind == US_SWITCH) 
+           {
+             utab = utab->env;
+             llassert (utab != GLOBAL_ENV);
+           }
+       } else 
+         {
+           llcontbug (message ("exitScope: in branch: %q", usymtab_unparseStack ()));
+           /*@-branchstate@*/ 
+         } /*@=branchstate@*/
+    }
+  
   /*
   ** check all variables in scope were used
   */
@@ -4381,7 +4491,7 @@ void usymtab_exitScope (exprNode expr)
   ** NOTE: note for exiting paramsScope, since checkReturn should be
   ** called first.
   */
-
+  
   if (!mustReturn && (usymtab_lexicalLevel () > functionScope))
     {
       /*
@@ -4400,7 +4510,6 @@ void usymtab_exitScope (exprNode expr)
       uentryList params = context_getParams ();
       globSet    globs = context_getUsedGlobs ();
 
-                  
       uentryList_elements (params, ue)
        {
          uentry_fixupSref (ue);
@@ -4408,13 +4517,16 @@ void usymtab_exitScope (exprNode expr)
 
       clearFunctionTypes ();
 
-      
+      DPRINTF (("Fixing up globals: %s", globSet_unparse (globs)));
+
       globSet_allElements (globs, el)
        {
+         DPRINTF (("Fix: %s", sRef_unparseDebug (el)));
+
          if (sRef_isCvar (el))
            {
              uentry current;
-             int index = sRef_getScopeIndex (el);
+             usymId index = sRef_getScopeIndex (el);
              
              if (sRef_isFileStatic (el))
                {
@@ -4428,13 +4540,17 @@ void usymtab_exitScope (exprNode expr)
              
              if (uentry_isVariable (current))
                {
+                 DPRINTF (("Fixup: %s", uentry_unparse (current)));
                  uentry_fixupSref (current);
                }
              else
                {
+                 DPRINTF (("Clear: %s", uentry_getSref (current)));
                  sRef_clearDerived (uentry_getSref (current));
                }
            }
+
+         sRef_clearDerived (el); /* evans 2002-03-14 - this is the likely source of many crashes! */
        } end_globSet_allElements;
     }
   
@@ -4445,7 +4561,12 @@ void usymtab_exitScope (exprNode expr)
       /*@i@*/ lctab->env = utab;  
       /*@i@*/ utab = ctab;
     /*@-branchstate@*/ } /*@=branchstate@*/
-/*@-globstate@*/
+  /*@-globstate@*/
+
+
+# ifdef DEBUGSPLINT
+  usymtab_checkAllValid ();
+# endif
 }
 /*@=globstate@*/
 
@@ -4453,8 +4574,8 @@ void usymtab_exitScope (exprNode expr)
 ** yikes!  don't let the '170 kids see this one...
 */
 
-int
-uentry_directParamNo (uentry ue)
+usymId
+usymtab_directParamNo (uentry ue)
 {
   if (uentry_isVar (ue))
     {
@@ -4462,21 +4583,15 @@ uentry_directParamNo (uentry ue)
 
       if (sRef_lexLevel (sr) == functionScope)
        {
-         int index;
+         usymId index = sRef_getScopeIndex (sr);
 
-         /*@access sRef@*/ 
-         llassert (sr->info != NULL);
-         llassert (sr->info->cvar != NULL);
-         index = sr->info->cvar->index;
-         /*@noaccess sRef@*/
-
-         if (index < uentryList_size (context_getParams ()))
+         if (index < usymId_fromInt (uentryList_size (context_getParams ())))
            {
              return index;
            }
        }
     }
-  return -1;
+  return usymId_invalid;
 }
 
 /*@dependent@*/ /*@exposed@*/ uentry
@@ -4612,7 +4727,7 @@ static /*@dependent@*/ /*@exposed@*/ usymtab
       s = usymtab_dropEnv (s);
     }
  
-  if (index >= s->nentries)
+  if (index >= usymId_fromInt (s->nentries))
     {
       return uentry_undefined;
     }
@@ -4670,7 +4785,6 @@ usymtab_getRefNoisy (/*@notnull@*/ usymtab s, int level, usymId index)
   while (usymtab_isBranch (s) && s->lexlevel == level)
     {
       int eindex = refTable_lookup (s, level, index);
-
       
       if (eindex != NOT_FOUND)
        {
@@ -4697,7 +4811,7 @@ usymtab_getRefNoisy (/*@notnull@*/ usymtab s, int level, usymId index)
       s = usymtab_dropEnv (s);
           }
 
-  if (s->lexlevel == level && (index < s->nentries))
+  if (s->lexlevel == level && (index < usymId_fromInt (s->nentries)))
     {
       ue = s->entries[index];
       
@@ -4726,7 +4840,7 @@ usymtab_getRefNoisy (/*@notnull@*/ usymtab s, int level, usymId index)
     }
 
   
-  if (index >= s->nentries)
+  if (index >= usymId_fromInt (s->nentries))
     {
       return uentry_undefined;
     }
@@ -4744,7 +4858,7 @@ usymtab_getRefNoisy (/*@notnull@*/ usymtab s, int level, usymId index)
 */
 
 static
-int refTable_lookup (/*@notnull@*/ usymtab ut, int level, int index)
+int refTable_lookup (/*@notnull@*/ usymtab ut, int level, usymId index)
 {
   refTable rt = ut->reftable;
   int i;
@@ -4753,7 +4867,7 @@ int refTable_lookup (/*@notnull@*/ usymtab ut, int level, int index)
 
   for (i = 0; i < ut->nentries; i++)
     {
-      if (rt[i]->level == level && rt[i]->index == index)
+      if (rt[i]->level == level && rt[i]->index == usymId_toInt (index))
        {
          return i;
        }
@@ -4776,7 +4890,6 @@ static
 static /*@dependent@*/ /*@exposed@*/ uentry
 usymtab_addRefEntry (/*@notnull@*/ usymtab s, cstring k)
 {
-  int eindex;
   usymtab ut = s;
 
   if (ut->reftable == NULL) 
@@ -4789,9 +4902,9 @@ usymtab_addRefEntry (/*@notnull@*/ usymtab s, cstring k)
   
   while (s != GLOBAL_ENV)
     {
-      eindex = usymtab_getIndex (s, k);
+      usymId eindex = usymtab_getIndex (s, k);
       
-      if (eindex != NOT_FOUND)
+      if (usymtab_indexFound (eindex))
        {
          uentry current = s->entries[eindex];
 
@@ -4800,7 +4913,15 @@ usymtab_addRefEntry (/*@notnull@*/ usymtab s, cstring k)
              uentry ue;
 
              DPRINTF (("Here: copying %s", uentry_unparse (current)));
-             ue = uentry_copy (current);
+             if (uentry_isNonLocal (current))
+               {
+                 ue = uentry_copy (current);
+               }
+             else
+               {
+                 ue = uentry_copyNoSave (current);
+               }
+
              DPRINTF (("Here: copying %s", uentry_unparse (ue)));
              usymtab_addEntryQuiet (ut, ue);
              DPRINTF (("Okay..."));
@@ -4815,7 +4936,7 @@ usymtab_addRefEntry (/*@notnull@*/ usymtab s, cstring k)
              else
                {
                  ut->reftable[ut->nentries - 1] 
-                   = refentry_create (s->lexlevel, eindex);
+                   = refentry_create (s->lexlevel, usymId_toInt (eindex));
                }
              
              return (ue);
@@ -4838,9 +4959,9 @@ static uentry usymtab_lookupAux (usymtab s, cstring k)
 
   while (s != GLOBAL_ENV)
     {
-      int eindex = usymtab_getIndex (s, k);
+      usymId eindex = usymtab_getIndex (s, k);
 
-      if (eindex != NOT_FOUND)
+      if (usymtab_indexFound (eindex))
        {
          uentry ret = s->entries[eindex];
 # if 0   
@@ -4881,13 +5002,11 @@ static uentry usymtab_lookupAux (usymtab s, cstring k)
 static /*@dependent@*/ /*@exposed@*/ uentry
 usymtab_lookupQuietAux (usymtab s, cstring k, bool noalt)
 {
-  int eindex;
-
   while (s != GLOBAL_ENV)
     {
-      eindex = usymtab_getIndex (s, k);
+      usymId eindex = usymtab_getIndex (s, k);
       
-      if (eindex != NOT_FOUND)
+      if (usymtab_indexFound (eindex))
        {
          uentry ret = s->entries[eindex];
          return (ret);
@@ -4899,6 +5018,7 @@ usymtab_lookupQuietAux (usymtab s, cstring k, bool noalt)
        }
       else
        {
+         llassert (s != NULL); 
          s = s->env;
        }
     }
@@ -4926,6 +5046,35 @@ usymtab_lookupQuietNoAlt (usymtab s, cstring k)
   return (usymtab_lookupAux (utab, k));
 }
 
+/*@dependent@*/ /*@observer@*/ uentry
+  usymtab_lookupSafeScope (cstring k, int lexlevel)
+  /*@globals utab@*/
+{
+  /*
+  ** This is necessary to deal with shadowed variables that are referenced
+  ** through aliases inside the shadowed scope.  It would be better if
+  ** lookup could take an sRef as a parameter.
+  */
+
+  usymtab tab = utab;
+
+  while (tab != GLOBAL_ENV && tab->lexlevel > lexlevel) {
+    uentry ret = usymtab_lookupAux (tab, k);
+    
+    if (uentry_isValid (ret)) {
+      sRef sr = uentry_getSref (ret);
+      
+      if (sRef_isCvar (sr) && sRef_lexLevel (sr) > lexlevel) {
+       tab = usymtab_dropEnv (tab);
+      } else {
+       return ret;
+      }
+    }
+  }
+
+  return uentry_undefined;
+}
+
 uentry
   usymtab_lookupExpose (cstring k)
   /*@globals utab@*/
@@ -4961,6 +5110,7 @@ uentry usymtab_lookupGlob (cstring k)
   if (uentry_isPriv (ce))
     llfatalbug (message ("usymtab_lookup: private: %s", k));
 
+  DPRINTF (("Lookup global: %s", uentry_unparseFull (ce)));
   return ce;
 }
 
@@ -4969,7 +5119,7 @@ uentry usymtab_lookupGlob (cstring k)
   /*@globals globtab@*/
 {
   uentry ce = usymtab_lookupAux (globtab, k);
-
+  DPRINTF (("Lookup global: %s", uentry_unparseFull (ce)));
   return ce;
 }
 
@@ -4981,17 +5131,17 @@ uentry usymtab_lookupEither (cstring k)
   if (uentry_isUndefined (ce))
     llfatalerror (message ("usymtab_lookup: not found: %s", k));
 
+  DPRINTF (("Lookup either: %s", uentry_unparseFull (ce)));
   return ce;
 }
 
-# ifndef NOLCL
 ctype
 usymtab_lookupType (cstring k)
    /*@globals globtab@*/
 {
-  usymId uid = usymtab_getTypeId (k);
+  typeId uid = usymtab_getTypeId (k);
 
-  if (uid == USYMIDINVALID)
+  if (typeId_isInvalid (uid))
     {
       llcontbug (message ("usymtab_lookupType: not found: %s", k));
       return ctype_unknown;
@@ -4999,14 +5149,13 @@ usymtab_lookupType (cstring k)
   
   return (uentry_getRealType (usymtab_getTypeEntry (uid)));
 }
-# endif
 
 ctype
 usymtab_lookupAbstractType (cstring k) /*@globals globtab@*/
 {
-  usymId uid = usymtab_getTypeId (k);
+  typeId uid = usymtab_getTypeId (k);
 
-  if (uid == USYMIDINVALID)
+  if (typeId_isInvalid (uid))
     {
       llcontbug (message ("usymtab_lookupType: not found: %s", k));
       return ctype_unknown; 
@@ -5134,7 +5283,6 @@ bool
   return (!(uentry_isUndefined (ce)) && !(uentry_isPriv (ce)));
 }
 
-# ifndef NOLCL
 bool
 usymtab_existsEither (cstring k)
   /*@globals utab@*/
@@ -5152,7 +5300,6 @@ bool
   
   return (uentry_isValid (ce));
 }
-# endif
 
 bool
 usymtab_existsType (cstring k)
@@ -5202,7 +5349,6 @@ usymtab_existsEnumTag (cstring k) /*@globals globtab@*/
   return (!(uentry_isUndefined (ce)) && !(uentry_isPriv (ce)));
 }
 
-# ifndef NOLCL
 bool usymtab_existsVar (cstring k)
    /*@globals utab@*/
 {
@@ -5210,7 +5356,6 @@ bool usymtab_existsVar (cstring k)
 
   return (!(uentry_isUndefined (ce)) && !(uentry_isPriv (ce)) && (uentry_isVar (ce)));
 }
-# endif
 
 /*
 ** destructors
@@ -5238,6 +5383,7 @@ usymtab_freeLevel (/*@notnull@*/ /*@only@*/ usymtab u)
 {
   int i;
 
+  DPRINTF (("Free level [%p]", u));
   aliasTable_free (u->aliases);
 
   refTable_free (u->reftable, u->nentries);
@@ -5246,7 +5392,10 @@ usymtab_freeLevel (/*@notnull@*/ /*@only@*/ usymtab u)
     {
       for (i = 0; i < u->nentries; i++)
        {
+         DPRINTF (("Free complete: %d", i));
+         DPRINTF (("Uentry: %s", uentry_unparse (u->entries[i])));
          uentry_freeComplete (u->entries[i]);
+         u->entries[i] = uentry_undefined;
        }
     }
   else
@@ -5254,6 +5403,7 @@ usymtab_freeLevel (/*@notnull@*/ /*@only@*/ usymtab u)
       for (i = 0; i < u->nentries; i++)
        {
          uentry_free (u->entries[i]);
+         u->entries[i] = uentry_undefined;
        }
     }
 
@@ -5265,11 +5415,10 @@ usymtab_freeLevel (/*@notnull@*/ /*@only@*/ usymtab u)
       && u != filetab)
     {
       llassert (!cstringTable_isDefined (u->htable));
-      sfree (u);
     }
 
-/*@-mustfree@*/
-} /*@=mustfree@*/
+  sfree (u); /* evans 2002-07-12: was inside if */
+}
 
 static void
 usymtab_freeAux (/*@only@*/ usymtab u)
@@ -5292,7 +5441,9 @@ void usymtab_free ()
 {
   dbgfree = TRUE;
   usymtab_freeAux (utab);
-}
+  utab = usymtab_undefined;
+  /*@-globstate@*/
+} /*@=globstate@*/ /* Splint cannot tell that utab is killed */
 
 static int usymtab_lexicalLevel (void) /*@globals utab@*/
 {
@@ -5314,7 +5465,6 @@ bool usymtab_inFunctionScope () /*@globals utab@*/
   return (utab->lexlevel == functionScope);
 }
 
-# ifndef NOLCL
 void
 usymtab_replaceEntry (uentry s)
   /*@globals utab, globtab@*/
@@ -5322,10 +5472,9 @@ usymtab_replaceEntry (uentry s)
 {
   usymtab_replaceEntryAux (utab, s);
 }
-# endif
 
 bool
-usymtab_matchForwardStruct (usymId u1, usymId u2)
+usymtab_matchForwardStruct (typeId u1, typeId u2)
    /*@globals globtab@*/
 {
   uentry ue1 = usymtab_getTypeEntry (u1);
@@ -5345,10 +5494,9 @@ usymtab_matchForwardStruct (usymId u1, usymId u2)
 
              if (u2 == rtuid) return TRUE;
              
-             if (usymId_isValid (rtuid))
+             if (typeId_isValid (rtuid))
                {
-                 reptype = uentry_getType (usymtab_getTypeEntry (rtuid));
-                 
+                 reptype = uentry_getType (usymtab_getTypeEntry (rtuid));                
                  return (ctype_isUA (reptype) && (u2 == (ctype_typeId (reptype))));
                }
            }
@@ -5380,6 +5528,10 @@ static bool usymtab_isGuardedAux (sRef s)
   
   while (tab->lexlevel >= lowlevel)
     {
+      DPRINTF (("Is guarded? [%s] %s", 
+               guardSet_unparse (tab->guards),
+               sRef_unparseFull (s)));
+
       if (guardSet_isGuarded (tab->guards, s))
        {
          /*
@@ -5423,7 +5575,7 @@ void usymtab_unguard (sRef s) /*@modifies utab@*/
 
 bool usymtab_isGuarded (sRef s)
 {
-  
+  DPRINTF (("Is guarded? %s", sRef_unparseFull (s)));
   return (sRef_aliasCompleteSimplePred (usymtab_isGuardedAux, s));
 }
 
@@ -5507,7 +5659,7 @@ usymtab_displayAllUses ()
 
   usymtab_entries (copy, ue)
     {
-      if (uentry_isValid (ue))
+      if (uentry_isValid (ue) && !uentry_isGlobalMarker (ue))
        {
          filelocList uses = uentry_getUses (ue);
          int size = filelocList_realSize (uses);
@@ -5599,6 +5751,7 @@ void usymtab_addMustAlias (/*@exposed@*/ sRef s, /*@exposed@*/ sRef al)
 void usymtab_addForceMustAlias (/*@exposed@*/ sRef s, /*@exposed@*/ sRef al)
   /*@modifies utab@*/
 {
+  /* evans 2002-03-3: was sRef_isMeaningful -- but we need to keep aliases for new storage also! */
   if (sRef_isMeaningful (s) 
       && sRef_isMeaningful (al)
       && !(sRef_isConst (s) || sRef_isConst (al))
@@ -5618,10 +5771,17 @@ void usymtab_addForceMustAlias (/*@exposed@*/ sRef s, /*@exposed@*/ sRef al)
     }
   else
     {
-      ;
+      DPRINTF (("Not aliasing! %s / %s", sRef_unparseFull (s), sRef_unparseFull (al)));
+      DPRINTF (("meaningful: %d %d", sRef_isMeaningful (s), sRef_isMeaningful (al)));
     }
 }
 
+void usymtab_addReallyForceMustAlias (/*@exposed@*/ sRef s, /*@exposed@*/ sRef al)
+  /*@modifies utab@*/
+{
+  utab->aliases = aliasTable_addMustAlias (utab->aliases, s, al); 
+}
+
 void usymtab_clearAlias (sRef s)
   /*@modifies utab, s@*/
 {
@@ -5632,7 +5792,7 @@ void usymtab_clearAlias (sRef s)
 sRefSet usymtab_allAliases (sRef s)
    /*@globals utab@*/  
 {
-  if (sRef_isMeaningful (s))
+  if (sRef_isSomewhatMeaningful (s))
     {
       sRefSet ret;
             
@@ -5650,7 +5810,7 @@ sRefSet usymtab_allAliases (sRef s)
 /*@only@*/ sRefSet usymtab_canAlias (sRef s)
      /*@globals utab@*/
 {
-  if (sRef_isMeaningful (s))
+  if (sRef_isSomewhatMeaningful (s))
     {
       sRefSet res = aliasTable_canAlias (utab->aliases, s);
       return res;
@@ -5687,7 +5847,7 @@ usymtab_printOut (void)
   int depth = 0;
   char *ind = mstring_copy ("               ");
 
-  fprintf (g_msgstream, "<<< [symbol table] >>>\n");
+  fprintf (g_warningstream, "<<< [symbol table] >>>\n");
   
   while (s != GLOBAL_ENV && s->env != GLOBAL_ENV)
     {
@@ -5698,7 +5858,7 @@ usymtab_printOut (void)
          ind[depth * 3 + 1] = '\0';
        }
      
-      fprintf (g_msgstream, "level: %d (%s)\n", s->lexlevel,
+      fprintf (g_warningstream, "level: %d (%s)\n", s->lexlevel,
               cstring_toCharsSafe (tname));
 
       cstring_free (tname);
@@ -5706,17 +5866,17 @@ usymtab_printOut (void)
       for (i = 0; i < s->nentries; i++)
        {
          cstring us = uentry_unparseFull (s->entries[i]);
-         fprintf (g_msgstream, "%s\n", cstring_toCharsSafe (us));
+         fprintf (g_warningstream, "%s\n", cstring_toCharsSafe (us));
          cstring_free (us);
        }
       
       if (s->reftable != NULL && s->nentries > 0)
        {
-         fprintf (g_msgstream, "\t<< Ref table >>\n");
+         fprintf (g_warningstream, "\t<< Ref table >>\n");
 
          for (i = 0; i < s->nentries; i++)
            {
-             fprintf (g_msgstream, "\t%s %3d: %d, %d\n", ind, i, 
+             fprintf (g_warningstream, "\t%s %3d: %d, %d\n", ind, i, 
                       s->reftable[i]->level,
                       s->reftable[i]->index);
            }
@@ -5726,7 +5886,7 @@ usymtab_printOut (void)
       depth++;
       s = s->env;
     }
-  fprintf (g_msgstream, "<<< end usymtab >>>\n");
+  fprintf (g_warningstream, "<<< end usymtab >>>\n");
   mstring_free (ind);
   return;
 }
@@ -5747,7 +5907,7 @@ usymtab_printAll (void)
 
 static void
 usymtab_printAllAux (usymtab s)
-   /*@modifies g_msgstream@*/
+   /*@modifies g_warningstream@*/
 {
   int i;
   int depth = 0;
@@ -5823,7 +5983,7 @@ usymtab_printComplete ()
          for (i = looplow; i < s->nentries; i++)
            {
              printf ("%s%3d %s\n", ind, i, 
-                     cstring_toCharsSafe (uentry_unparse (s->entries[i])));
+                     cstring_toCharsSafe (uentry_unparseFull (s->entries[i])));
            }
        }
       else
@@ -5832,7 +5992,7 @@ usymtab_printComplete ()
          for (i = 0; i < s->nentries; i++)
            {
              printf ("%s%3d %s\n", ind, i, 
-                    cstring_toCharsSafe (uentry_unparse (s->entries[i])));
+                    cstring_toCharsSafe (uentry_unparseFull (s->entries[i])));
            }
        }
       
@@ -5845,6 +6005,7 @@ usymtab_printComplete ()
   mstring_free (ind);
 }
 
+# ifdef S_SPLINT_S
 static /*@only@*/ cstring /*@unused@*/ 
 usymtab_unparseLocalAux (/*@notnull@*/ usymtab s)
 {
@@ -5860,7 +6021,6 @@ usymtab_unparseLocalAux (/*@notnull@*/ usymtab s)
   return (c);
 }
 
-# if 0
 static cstring /*@unused@*/ /*@only@*/ 
 usymtab_unparseLocalList (/*@notnull@*/ usymtab s)
 {
@@ -5923,9 +6083,9 @@ usymtab_printLocal (void)
 
 static bool checkDistinctExternalName (uentry e)
   /*@globals globtab@*/
-  /*@modifies *g_msgstream@*/
+  /*@modifies *g_warningstream@*/
 {
-  int checklen = context_getValue (FLG_EXTERNALNAMELEN);
+  size_t checklen = size_fromInt (context_getValue (FLG_EXTERNALNAMELEN));
   bool ignorecase = context_getFlag (FLG_EXTERNALNAMECASEINSENSITIVE);
   bool gotone = FALSE;
   bool extras = FALSE;
@@ -6000,7 +6160,7 @@ static bool checkDistinctExternalName (uentry e)
                            "in the first %d characters (%q)",
                            uentry_getName (e),
                            uentry_getName (oe),
-                           checklen,
+                           size_toInt (checklen),
                            cstring_clip (uentry_getName (e), checklen)),
                           /*@=sefparams@*/
                           uentry_whereLast (e)))
@@ -6026,7 +6186,7 @@ static bool checkDistinctExternalName (uentry e)
                            "is ignored",
                            uentry_getName (e),
                            uentry_getName (oe),
-                           checklen),
+                           size_toInt (checklen)),
                           uentry_whereLast (e)))
                        {
                          uentry_showWhereAny (oe);
@@ -6052,7 +6212,7 @@ static bool checkDistinctExternalName (uentry e)
                    "in the first %d characters (%q)",
                    uentry_getName (e),
                    uentry_getName (oe),
-                   checklen,
+                   size_toInt (checklen),
                    cstring_clip (uentry_getName (e), checklen)),
                   /*@=sefparams@*/
                   uentry_whereLast (e)))
@@ -6084,11 +6244,11 @@ static bool checkDistinctExternalName (uentry e)
 
 static bool checkDistinctInternalName (uentry e)
   /*@globals utab@*/
-  /*@modifies *g_msgstream@*/
+  /*@modifies *g_warningstream@*/
 {
   usymtab ttab = utab;
   cstring name = uentry_rawName (e);
-  int numchars = context_getValue (FLG_INTERNALNAMELEN);
+  size_t numchars = size_fromInt (context_getValue (FLG_INTERNALNAMELEN));
   bool caseinsensitive = context_getFlag (FLG_INTERNALNAMECASEINSENSITIVE);
   bool lookalike = context_getFlag (FLG_INTERNALNAMELOOKALIKE);
 
@@ -6128,7 +6288,7 @@ static bool checkDistinctInternalName (uentry e)
                        "in the first %d characters (%q)",
                        uentry_getName (e),
                        uentry_getName (oe),
-                       numchars,
+                       size_toInt (numchars),
                        cstring_clip (uentry_getName (e), numchars)),
                       /*@=sefparams@*/
                       uentry_whereLast (e)))
@@ -6141,8 +6301,7 @@ static bool checkDistinctInternalName (uentry e)
              /*@switchbreak@*/
              break;
            case CGE_CASE:
-             if (numchars == 0 
-                 || (cstring_length (name) <= numchars))
+             if (numchars == 0 || (cstring_length (name) <= numchars))
                {
                  if (optgenerror 
                      (FLG_DISTINCTINTERNALNAMES,
@@ -6167,7 +6326,7 @@ static bool checkDistinctInternalName (uentry e)
                        "in the first %d characters without case sensitivity",
                        uentry_getName (e),
                        uentry_getName (oe),
-                       numchars),
+                       size_toInt (numchars)),
                       uentry_whereLast (e)))
                    {
                      uentry_showWhereAny (oe);
@@ -6204,7 +6363,7 @@ static bool checkDistinctInternalName (uentry e)
                        "in the first %d characters except by lookalike characters",
                        uentry_getName (e),
                        uentry_getName (oe),
-                       numchars),
+                       size_toInt (numchars)),
                       uentry_whereLast (e)))
                    {
                      uentry_showWhereAny (oe);
@@ -6259,3 +6418,36 @@ void usymtab_checkDistinctName (uentry e, int scope)
   return uentry_getSref (ue);
 }
 
+
+# ifdef DEBUGSPLINT
+/*
+** For debugging only
+*/
+
+void
+usymtab_checkAllValid () /*@globals utab@*/ 
+{
+  usymtab tab = utab;
+
+  while (tab != GLOBAL_ENV)
+    {
+      int i;
+
+      for (i = 0; i < utab->nentries; i++)
+       {
+         uentry e = utab->entries[i];
+         
+         uentry_checkValid (e);
+       }
+
+      aliasTable_checkValid (tab->aliases);
+      tab = tab->env;
+    }
+}
+# endif
+
+
+
+
+
+
This page took 1.878329 seconds and 4 git commands to generate.