]> andersk Git - splint.git/blobdiff - src/uentry.c
Modified the doc/Makefile.am so that the man page is install under make install.
[splint.git] / src / uentry.c
index 8f235224ae5295897c38bfed0e6a26913a95f4d7..ac39bb6ba577df17170f97cd93e2aca70873a051 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ** Splint - annotation-assisted static program checker
-** Copyright (C) 1994-2001 University of Virginia,
+** Copyright (C) 1994-2002 University of Virginia,
 **         Massachusetts Institute of Technology
 **
 ** This program is free software; you can redistribute it and/or modify it
 ** 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 information on splint: info@splint.org
+** To report a bug: splint-bug@splint.org
 ** For more information: http://www.splint.org
 */
 /*
 ** uentry.c
 */
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "basic.h"
 # include "structNames.h"
 # include "nameChecks.h"
@@ -43,7 +43,7 @@ static bool uentry_isReallySpecified (uentry p_e) /*@*/ ;
 static void uentry_checkIterArgs (uentry p_ue);
 static cstring uentry_dumpAux (uentry p_v, bool p_isParam);
 
-static void uentry_showWhereLastKind (uentry p_spec) /*@*/ ; 
+static void uentry_showWhereLastKind (uentry p_spec) /*@modifies g_msgstream@*/ ; 
 
 static void uentry_combineModifies (uentry p_ue, /*@owned@*/ sRefSet p_sr) 
      /*@modifies p_ue@*/ ;
@@ -92,6 +92,11 @@ static /*@only@*/ /*@notnull@*/ uentry
   uentry_makeVariableAux (cstring p_n, ctype p_t, /*@keep@*/ fileloc p_f,
                          /*@exposed@*/ sRef p_s, bool p_priv, vkind p_kind);
 
+static /*@only@*/ /*@notnull@*/ uentry 
+  uentry_makeConstantAux (cstring p_n, ctype p_t, 
+                         /*@keep@*/ fileloc p_f, bool p_priv, bool p_macro,
+                         /*@only@*/ multiVal p_m) /*@*/ ;
+
 static void uentry_convertVarFunction (uentry ue) /*@modifies ue@*/
 {
   if (uentry_isVariable (ue) 
@@ -572,12 +577,12 @@ static constraintList uentry_getFunctionConditions (uentry ue, bool isPost)
     {
       functionConstraint constraint;
 
-      DPRINTF( (message ("called uentry_getFcnPostconditions on  %s",
+      DPRINTF((message ("called uentry_getFcnPostconditions on  %s",
                         uentry_unparse (ue) ) ) );
       
       if (uentry_isVariable (ue) && ctype_isFunction (uentry_getType (ue)))
        {
-         DPRINTF( (message ("called uentry_getFunctionConditions on nonfunction %s",
+         DPRINTF((message ("called uentry_getFunctionConditions on nonfunction %s",
                             uentry_unparse (ue) ) ) );
          if (!uentry_isFunction (ue) )
            {
@@ -593,7 +598,7 @@ static constraintList uentry_getFunctionConditions (uentry ue, bool isPost)
       if (!uentry_isFunction(ue))
        {
          
-         DPRINTF( (message ("called uentry_getFunctionConditions on non function  %s",
+         DPRINTF((message ("called uentry_getFunctionConditions on non function  %s",
                             uentry_unparse (ue) ) ) );
          return constraintList_undefined;
          
@@ -1037,7 +1042,9 @@ static void uentry_reflectClauses (uentry ue, functionClauseList clauses)
            }
          else
            {
+             DPRINTF (("Taking globs: %s", globalsClause_unparse (glc)));
              uentry_setGlobals (ue, globalsClause_takeGlobs (glc));
+             DPRINTF (("Taking globs after: %s", globalsClause_unparse (glc)));
            }
        }
       else if (functionClause_isModifies (el))
@@ -1613,7 +1620,7 @@ uentry_setPreconditions (uentry ue, /*@only@*/ functionConstraint preconditions)
       
       if (functionConstraint_isDefined (ue->info->fcn->preconditions))
        {
-         /* drl 11-29-2001
+         /* drl 11-29-2002
             I changed this so it didn't appear as a Splint bug
             among other things this gets triggered when there is
             a function with two requires clauses.  Now Splint
@@ -1636,7 +1643,7 @@ uentry_setPreconditions (uentry ue, /*@only@*/ functionConstraint preconditions)
     }
   else
     {
-      llfatalbug ( (message("uentry_setPreconditions called with invalid uentry") ));
+      llfatalbug ((message("uentry_setPreconditions called with invalid uentry") ));
     }
 }
 
@@ -1673,7 +1680,7 @@ uentry_setPostconditions (uentry ue, /*@only@*/ functionConstraint postcondition
     }
   else
     {
-      llfatalbug ( (message("uentry_setPostconditions called with invalid uentry") ));
+      llfatalbug ((message("uentry_setPostconditions called with invalid uentry") ));
     }
 }
 
@@ -3101,9 +3108,9 @@ uentry_isSpecialFunction (uentry ue)
 ** constants
 */
 
-/*@only@*/ /*@notnull@*/ 
+static /*@only@*/ /*@notnull@*/ 
 uentry uentry_makeConstantAux (cstring n, ctype t, 
-                              /*@keep@*/ fileloc f, bool priv,
+                              /*@keep@*/ fileloc f, bool priv, bool macro,
                               /*@only@*/ multiVal m)
 {
   uentry e = uentry_alloc ();
@@ -3127,6 +3134,7 @@ uentry uentry_makeConstantAux (cstring n, ctype t,
   e->info = (uinfo) dmalloc (sizeof (*e->info));
   e->info->uconst = (ucinfo) dmalloc (sizeof (*e->info->uconst));
   e->info->uconst->access = typeIdSet_undefined;
+  e->info->uconst->macro = macro;
 
   uentry_setSpecDef (e, f);
 
@@ -3142,7 +3150,17 @@ uentry uentry_makeConstantAux (cstring n, ctype t,
 
 /*@notnull@*/ uentry uentry_makeConstant (cstring n, ctype t, fileloc f)
 {
-  return (uentry_makeConstantAux (n, t, f, FALSE, multiVal_unknown ()));
+  return (uentry_makeConstantAux (n, t, f, FALSE, FALSE, multiVal_unknown ()));
+}
+
+/*@notnull@*/ uentry uentry_makeConstantValue (cstring n, ctype t, fileloc f, bool priv, multiVal val)
+{
+  return (uentry_makeConstantAux (n, t, f, priv, FALSE, val));
+}
+
+/*@notnull@*/ uentry uentry_makeMacroConstant (cstring n, ctype t, fileloc f)
+{
+  return (uentry_makeConstantAux (n, t, f, FALSE, TRUE, multiVal_unknown ()));
 }
 
 /*@notnull@*/ uentry uentry_makeIdConstant (idDecl t)
@@ -3360,10 +3378,11 @@ void uentry_makeVarFunction (uentry ue)
   llassert (uentry_isVariable (ue));
   oldInfo = ue->info->var;
 
-  llassert (ctype_isUnknown (ue->utype) || ctype_isFunction (ue->utype));
+  DPRINTF (("ue: %s", uentry_unparseFull (ue)));
+  llassert (ctype_isUnknown (ue->utype) || ctype_isFunction (ctype_realType (ue->utype)));
 
   /*
-  ** expanded macro is marked used (until I write a pre-processor)
+  ** expanded macro is marked used 
   */
 
   ue->used = ue->used || (oldInfo->kind == VKEXPMACRO);
@@ -4154,7 +4173,7 @@ uentry_compare (uentry u1, uentry u2)
     {
     case KINVALID:
     case KELIPSMARKER:
-      /* bug detected by lclint:  
+      /* bug detected by splint:  
       ** uentry.c:753,14: Return value type bool does not match declared type int: TRUE 
       */
       return 0;
@@ -4281,7 +4300,7 @@ static uentry
   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 */
   uentry_setConstantValue (e, m);
   sRef_storeState (e->sref);
 
@@ -6598,6 +6617,7 @@ ucinfo_copy (ucinfo u)
 {
   ucinfo ret = (ucinfo) dmalloc (sizeof (*ret));
   ret->access = u->access;
+  ret->macro = u->macro;
   return ret;
 }
 
@@ -8227,7 +8247,7 @@ checkFunctionConformance (/*@unique@*/ /*@notnull@*/ uentry old,
   uentryList oldParams  = uentry_getParams (old);
   uentryList newParams  = uentry_getParams (unew);
   ctype      newType    = unew->utype;
-  ctype      oldType    = old->utype;
+  ctype      oldType    = ctype_realType (old->utype);
   ctype      oldRetType = ctype_unknown;
   ctype      newRetType = ctype_unknown;
 
@@ -8249,14 +8269,12 @@ checkFunctionConformance (/*@unique@*/ /*@notnull@*/ uentry old,
   if (ctype_isKnown (oldType))
     {
       llassert (ctype_isFunction (oldType));
-
       oldRetType = ctype_getReturnType (oldType);
     }
 
   if (ctype_isKnown (newType))
     {
       llassert (ctype_isFunction (newType));
-
       newRetType = ctype_getReturnType (newType);
     }
 
@@ -8521,7 +8539,7 @@ checkFunctionConformance (/*@unique@*/ /*@notnull@*/ uentry old,
 
              paramno++;  
              /*
-              ** Forgot this!  detected by lclint:
+              ** Forgot this!  detected by splint:
               ** uentry.c:1257,15: Suspected infinite loop
               */
            }
@@ -8576,8 +8594,8 @@ checkFunctionConformance (/*@unique@*/ /*@notnull@*/ uentry old,
          unew->info->fcn->specclauses = stateClauseList_undefined;
          /*@-branchstate@*/ 
        }
-      /*@=branchstate@*/ /*@i23 shouldn't need this@*/
     }
+  /*@=branchstate@*/ /*@i23 shouldn't need this@*/
 
   if (fileloc_isUndefined (old->whereDeclared))
     {
@@ -8591,7 +8609,7 @@ checkFunctionConformance (/*@unique@*/ /*@notnull@*/ uentry old,
     {
       /* no change */
     }
-}
+/*@i523 @*/ }
 
 void
 uentry_mergeConstantValue (uentry ue, /*@only@*/ multiVal m)
@@ -10468,6 +10486,8 @@ uentry_mergeState (uentry res, uentry other, fileloc loc,
   uentry_mergeAliasStates (res, other, loc, mustReturn, flip, opt, cl);
   uentry_mergeValueStates (res, other, loc, mustReturn, flip);
   uentry_mergeSetStates (res, other, loc, flip, cl);
+
+  DPRINTF (("Merge ==> %s", uentry_unparseFull (res)));
 }
 
 void uentry_setUsed (uentry e, fileloc loc)
@@ -11041,7 +11061,7 @@ void uentry_checkName (uentry ue)
   fileloc_free (tloc);
   uentry_setHasNameError (ue);
   
-  if (context_getFlag (FLG_REPEATUNRECOG))
+  if (context_getFlag (FLG_REPEATUNRECOG) || (context_inOldSytleScope() ) )
     {
       uentry_markOwned (ue);
     }
This page took 0.211232 seconds and 4 git commands to generate.