]> andersk Git - splint.git/blobdiff - src/usymtab.c
Updated copyright date.
[splint.git] / src / usymtab.c
index e01a65ed7fe9d032a4fb46536657e31d8c1e739e..278fbb9e41a325c82bdeab85bf7dcbaf5b5f2e62 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-2002 University of Virginia,
 **         Massachusetts Institute of Technology
 **
 ** This program is free software; you can redistribute it and/or modify it
@@ -19,7 +19,7 @@
 **
 ** 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 more information: http://www.splint.org
 */
 /*
 ** usymtab
@@ -112,10 +112,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 __LCLINT__
+/* 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@*/ 
@@ -150,9 +155,9 @@ static bool usymtab_mustEscape (usymtab p_s);
 
 static void recordFunctionType (uentry ue)
 {
-    llassert (uentry_isDatatype (ue) || uentry_isAnyTag (ue)
+  llassert (uentry_isDatatype (ue) || uentry_isAnyTag (ue)
            || uentry_isEnumConstant (ue));
-
+  DPRINTF (("Function type: %s", uentry_unparseFull (ue)));
   /*@-temptrans@*/
   functypes = uentryList_add (functypes, ue);
   /*@=temptrans@*/
@@ -853,13 +858,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)));
@@ -942,6 +955,9 @@ usymtab_supEntryAux (/*@notnull@*/ usymtab st,
       
       outer = usymtab_lookupQuiet (st->env, ename);
 
+      DPRINTF (("New  : [%p] %s", e, uentry_unparseFull (e)));
+      DPRINTF (("Outer: [%p] %s", outer, uentry_unparseFull (outer)));
+
       /*
       ** no previous definition, add the new one
       */
@@ -1094,6 +1110,12 @@ static /*@exposed@*/ uentry
 
   ret = usymtab_supEntryReturnAux (globtab, e, FALSE);
 
+  /*
+  ** We need to keep track of internal function declarations, so
+  ** we can remove them from the symbol table after exiting this
+  ** function.  This is a bit bogus, of course.
+  */
+
   if (sRef_modInFunction ())
     {
       recordFunctionType (ret);
@@ -1557,6 +1579,7 @@ usymtab_getTypeEntryName (usymId uid)
   return (uentry_getName (ue));
 }
 
+# if 0
 /*@unused@*/ static void
 usymtab_rehash (/*@notnull@*/ usymtab s)
 {
@@ -1574,6 +1597,7 @@ usymtab_rehash (/*@notnull@*/ usymtab s)
       cstringTable_insert (s->htable, cstring_copy (uentry_rawName (s->entries[i])), i);
     }
 }
+# endif
 
 /*
 ** superficial copy of usymtab
@@ -2277,7 +2301,7 @@ usymtab_enterFunctionScope (uentry fcn)
     {
       if (utab->lexlevel > fileScope)
        {
-         llparseerror (cstring_makeLiteral ("New function scope inside function."));
+         llparseerror (cstring_makeLiteral ("New function scope inside function"));
          
          while (utab->lexlevel > fileScope)
            {
@@ -3616,7 +3640,7 @@ checkGlobalReturn (uentry glob, sRef orig)
 {
   sRef sr = uentry_getSref (glob);
   
-  DPRINTF (("Check global return: %s // orig: %s // sr: %s",
+  DPRINTF (("Check global return: %s / orig: %s / sr: %s",
            uentry_unparseFull (glob),
            sRef_unparseFull (orig),
            sRef_unparseFull (sr)));
@@ -3676,16 +3700,25 @@ checkGlobalReturn (uentry glob, sRef orig)
            }
          else 
            {
-             if (sRef_isDead (sr))
+             if (sRef_isDead (sr) || sRef_isKept (sr))
                {
                  if (optgenerror 
                      (FLG_GLOBSTATE,
                       message ("Function returns with global %q "
-                               "referencing released storage",
-                               uentry_getName (glob)),
+                               "referencing %s storage",
+                               uentry_getName (glob),
+                               cstring_makeLiteralTemp (sRef_isDead (sr) ? "released" : "kept")),
                       g_currentloc))
                    {
-                     sRef_showStateInfo (sr);
+                     if (sRef_isKept (sr))
+                       {
+                         sRef_showAliasInfo (sr);      
+                       }
+                     else
+                       {
+                         sRef_showStateInfo (sr);
+                       }
+
                      sRef_setDefState (sr, SS_UNKNOWN, fileloc_undefined);
                    }
                }
@@ -3792,7 +3825,8 @@ void usymtab_checkFinalScope (bool isReturn)
                minfo = context_lookupMetaStateInfo (fkey);
                llassert (metaStateInfo_isDefined (minfo));
                
-               if (stateValue_isError (fval))
+               if (stateValue_isError (fval)
+                   || sRef_isStateUndefined (sr)) /* No errors for undefined state */
                  {
                    ;
                  }
@@ -4159,7 +4193,7 @@ void usymtab_checkFinalScope (bool isReturn)
                                        {
                                          ss (sr);
                                        }
-
+                                     
                                      DPRINTF (("Storage: %s", sRef_unparseFull (sr)));
                                    }  
                                }
@@ -4426,8 +4460,8 @@ void usymtab_exitScope (exprNode expr)
       /*@i@*/ lctab->env = utab;  
       /*@i@*/ utab = ctab;
     /*@-branchstate@*/ } /*@=branchstate@*/
-/*@-globstate@*/
-}
+  /*@-globstate@*/
+/*@i523@*/ }
 /*@=globstate@*/
 
 /*
@@ -5361,6 +5395,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))
        {
          /*
@@ -5404,7 +5442,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));
 }
 
@@ -5826,6 +5864,7 @@ usymtab_printComplete ()
   mstring_free (ind);
 }
 
+# ifdef __LCLINT__
 static /*@only@*/ cstring /*@unused@*/ 
 usymtab_unparseLocalAux (/*@notnull@*/ usymtab s)
 {
@@ -5868,6 +5907,7 @@ usymtab_unparseLocalList (/*@notnull@*/ usymtab s)
 
   return (c);
 }
+# endif
 
 void
 usymtab_printLocal (void)
This page took 0.346977 seconds and 4 git commands to generate.