]> andersk Git - splint.git/blobdiff - src/transferChecks.c
Fixes after removing -unrecogcomments flag for make splintme.
[splint.git] / src / transferChecks.c
index 89ebe754cf28780cf4495108e91faeddb1244261..fe12682be7a5c64cbce70f74842edde0cffc77e1 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ** Splint - annotation-assisted static program checker
-** Copyright (C) 1994-2002 University of Virginia,
+** Copyright (C) 1994-2003 University of Virginia,
 **         Massachusetts Institute of Technology
 **
 ** This program is free software; you can redistribute it and/or modify it
 ** 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
 */
 /*
 ** transferChecks.c
 */
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "basic.h"
 # include "transferChecks.h"
 
@@ -505,7 +505,8 @@ checkCompletelyDefined (exprNode fexp, /*@exposed@*/ sRef fref, sRef ofref,
            {
              ; /* no error (will be a definition error) */
            }
-         else if (transferType == TT_DOASSIGN)
+         else if (transferType == TT_DOASSIGN
+                  || transferType == TT_FIELDASSIGN) /* evans 2002-02-05 - added TT_FIELDASSIGN */
            {
              ; /* no error */
            }
@@ -775,6 +776,7 @@ checkCompletelyDefined (exprNode fexp, /*@exposed@*/ sRef fref, sRef ofref,
       else
        {
          llassert (transferType == TT_DOASSIGN
+                   || transferType == TT_FIELDASSIGN /* evans 2002-02-05: no warnings for local fields */
                    || transferType == TT_GLOBINIT
                    || transferType == TT_LEAVETRANS);
        }
@@ -1286,14 +1288,14 @@ static /*@observer@*/ cstring dscCode_unparse (dscCode desc) /*@*/
 }
 
 static bool 
-  checkCompletelyDestroyed (exprNode p_fexp, sRef p_fref, bool p_topLevel, 
-                           fileloc p_loc, int p_depth, dscCode p_desc,
-                           bool p_hideErrors);
+checkCompletelyDestroyed (exprNode p_fexp, sRef p_fref, bool p_topLevel, bool p_isField,
+                         fileloc p_loc, int p_depth, dscCode p_desc,
+                         bool p_hideErrors);
 
 bool transferChecks_globalDestroyed (sRef fref, fileloc loc)
 {
   DPRINTF (("Global destroyed: %s", sRef_unparseFull (fref)));
-  return (checkCompletelyDestroyed (exprNode_undefined, fref, TRUE,
+  return (checkCompletelyDestroyed (exprNode_undefined, fref, TRUE, FALSE,
                                    loc, 0, DSC_GLOB, FALSE));
 }
 
@@ -1306,7 +1308,7 @@ void transferChecks_localDestroyed (sRef fref, fileloc loc)
     }
   else
     {
-      (void) checkCompletelyDestroyed (exprNode_undefined, fref, TRUE,
+      (void) checkCompletelyDestroyed (exprNode_undefined, fref, TRUE, FALSE,
                                       loc, 0, DSC_LOCAL, FALSE);
     }
 }
@@ -1322,19 +1324,21 @@ void transferChecks_structDestroyed (sRef fref, fileloc loc)
     }
   else
     {
-      (void) checkCompletelyDestroyed (exprNode_undefined, fref, TRUE,
+      (void) checkCompletelyDestroyed (exprNode_undefined, fref, TRUE, FALSE,
                                       loc, 0, DSC_STRUCT, FALSE);
     }
 }
 
 static bool
-  checkCompletelyDestroyed (exprNode fexp, sRef fref, bool topLevel,
-                           fileloc loc, int depth,
-                           dscCode desc, bool hideErrors)
+checkCompletelyDestroyed (exprNode fexp, sRef fref, bool topLevel, bool isField,
+                         fileloc loc, int depth,
+                         dscCode desc, bool hideErrors)
 {
   ctype ct;
-
-  DPRINTF (("Check completely destroyed: %s", sRef_unparseFull (fref)));
+  
+  DPRINTF (("Check completely destroyed: %s / %s",
+           sRef_unparse (fref),
+           bool_unparse (hideErrors)));
 
   if (depth > MAXDEPTH)
     {
@@ -1394,14 +1398,16 @@ static bool
 
   if (sRef_isPdefined (fref) 
       && ctype_isAP (ct)
-      && !context_getFlag (FLG_STRICTDESTROY)) 
+      && !isField
+      && !context_getFlag (FLG_STRICTDESTROY))
     {
       /*
       ** Don't report errors for array elements (unless strictdestroy)
       ** when at least one appears to have been destroyed.
       */
 
-      DPRINTF (("Partial: %s", sRef_unparseFull (fref)));
+      DPRINTF (("Partial: %s / hiding errors: %s", sRef_unparseFull (fref),
+               ctype_unparse (ct)));
       hideErrors = TRUE;
       /* Don't report any more errors, but still change ownership. */
     }
@@ -1559,8 +1565,8 @@ static bool
       sRef fptr = sRef_constructDeadDeref (fref);
       bool res;
 
-      res = checkCompletelyDestroyed (fexp, fptr, FALSE, loc,
-                                     depth + 1, desc, hideErrors);
+      res = checkCompletelyDestroyed (fexp, fptr, FALSE, FALSE,
+                                     loc, depth + 1, desc, hideErrors);
       
       return res;
     }
@@ -1579,8 +1585,8 @@ static bool
        {
          sRef farr = sRef_constructDeadDeref (fref);
          
-         return (checkCompletelyDestroyed (fexp, farr, FALSE, loc, 
-                                           depth + 1, desc, hideErrors));
+         return (checkCompletelyDestroyed (fexp, farr, FALSE, FALSE,
+                                           loc, depth + 1, desc, hideErrors));
        }
     }
   else if (ctype_isStruct (ct))
@@ -1614,12 +1620,12 @@ static bool
              
              DPRINTF (("Check field: %s", sRef_unparseFull (field)));
 
-             isOk = (checkCompletelyDestroyed (fexp, field, FALSE, loc,
-                                               depth + 1, desc, hideErrors)
+             isOk = (checkCompletelyDestroyed (fexp, field, FALSE, TRUE,
+                                               loc, depth + 1, desc, hideErrors)
                      && isOk);
            } end_uentryList_elements;
        }
-
+      
       return isOk;
     }
   else
@@ -1651,7 +1657,7 @@ transferChecks_return (exprNode fexp, uentry rval)
     {
       if (stateClause_isGlobal (cl))
        {
-         ; /*@i32@*/
+         ; 
        }
       else if (stateClause_setsMetaState (cl))
        {
@@ -1689,7 +1695,6 @@ transferChecks_return (exprNode fexp, uentry rval)
                           exprNode_loc (fexp)))
                        {
                          sRef_showAliasInfo (sr); 
-                         /*@i32@*/
                        }
                    }
                }
@@ -1718,7 +1723,8 @@ transferChecks_return (exprNode fexp, uentry rval)
              DPRINTF (("el: %s / %s", sRef_unparse (el),
                        sRef_unparse (base)));
              
-             if (sRef_isResult (base))
+             if (sRef_isResult (base) 
+                 && !sRef_isDefinitelyNull (fref)) /* evans 2002-07-22: don't report allocation errors for null results */
                {
                  sRef sr = sRef_fixBase (el, fref);
                  
@@ -1944,8 +1950,8 @@ transferChecks_passParam (exprNode fexp, uentry arg, bool isSpec,
            }
        }
       
-      (void) checkCompletelyDestroyed (fexp, fref, TRUE, exprNode_loc (fexp),
-                                      0, DSC_PARAM, FALSE);
+      (void) checkCompletelyDestroyed (fexp, fref, TRUE, FALSE,
+                                      exprNode_loc (fexp), 0, DSC_PARAM, FALSE);
 
       /* make it defined now, so checkTransfer is okay */
       sRef_setDefined (fref, exprNode_loc (fexp)); 
@@ -2528,7 +2534,7 @@ checkTransferNullAux (sRef fref, exprNode fexp, /*@unused@*/ bool ffix,
              if (sRef_isNotNull (tref))
                {
                  if (optgenerror
-                     (FLG_SYNTAX, /*@i432 kuldge flag... */
+                     (FLG_NULLINIT, /* kuldge flag... */
                       message ("%s %q initialized to %s value: %q",
                                sRef_getScopeName (tref),
                                sRef_unparse (tref),
@@ -4011,7 +4017,6 @@ checkMetaStateConsistent (/*@exposed@*/ sRef fref, sRef tref,
          }
        else
          {
-           /*@i#!@!!@*/
            DPRINTF (("Cannot find meta state for: %s / to: %s / %s", sRef_unparseFull (fref),
                      sRef_unparseFull (tref),
                      fkey));
@@ -4132,7 +4137,7 @@ checkMetaStateConsistent (/*@exposed@*/ sRef fref, sRef tref,
 static void
 checkMetaStateTransfer (exprNode fexp, sRef fref, exprNode texp, sRef tref, 
                        exprNode fcn,
-                       fileloc loc, transferKind /*@i32@*/ transferType)
+                       fileloc loc, transferKind transferType)
 {
   valueTable fvalues = sRef_getValueTable (fref);
   valueTable tvalues = sRef_getValueTable (tref);
@@ -4170,7 +4175,6 @@ checkMetaStateTransfer (exprNode fexp, sRef fref, exprNode texp, sRef tref,
          }
        else
          {
-           /*@i#!@!!@*/
            DPRINTF (("Metastate transfer: %s => %s",
                      exprNode_unparse (fexp), exprNode_unparse (texp)));
            DPRINTF (("Cannot find meta state for: %s / to: %s / %s", sRef_unparseFull (fref),
@@ -4230,8 +4234,6 @@ checkMetaStateTransfer (exprNode fexp, sRef fref, exprNode texp, sRef tref,
              {
                if (nval == stateValue_error)
                  {
-                   /*@i32 print extra info for assignments@*/
-                   
                    if (optgenerror 
                        (FLG_STATETRANSFER,
                         message
This page took 0.084536 seconds and 4 git commands to generate.