]> andersk Git - splint.git/blobdiff - src/exprChecks.c
Fixed all /*@i...@*/ tags (except 1).
[splint.git] / src / exprChecks.c
index 70aadcaf58188d8fbdfcbda80d2910ba4ceef854..9bc78f208a55fe4e23392158798439a75d034974 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
 */
 /*
 ** exprChecks.c
 */
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "basic.h"
 # include "cgrammar.h"
 # include "cgrammar_tokens.h"
@@ -52,11 +52,36 @@ static void checkSafeReturnExpr (/*@notnull@*/ exprNode p_e);
 **
 */
 
+static int inCompoundStatementExpression = 0;
+
+void
+exprChecks_inCompoundStatementExpression (void)
+{
+  inCompoundStatementExpression++;
+}
+
 void
-exprNode_checkStatement (exprNode e)
+exprChecks_leaveCompoundStatementExpression (void)
+{
+  inCompoundStatementExpression--;
+  llassert (inCompoundStatementExpression >= 0);
+}
+
+void
+exprChecks_checkStatementEffect (exprNode e)
 {
   bool hasError = FALSE;
 
+  if (inCompoundStatementExpression > 0)
+    {
+      /*
+      ** Okay to have effectless statments in compound statement expression (should check
+      ** it is the last statement, but we don't for now).
+      */
+
+      return;
+    }
+
   if (!exprNode_isError (e))
     {
       exprKind ek = e->kind;
@@ -239,13 +264,13 @@ checkRefGlobParam (sRef base, /*@notnull@*/ exprNode e,
          else if (sRef_isAnyParam (base))
            {
              uentryList params = context_getParams ();
-             int paramno = sRef_getParam (base);
+             int paramno = usymId_toInt (sRef_getParam (base));
 
              if (paramno < uentryList_size (params))
                {
                  uentry arg = uentryList_getN (params, paramno);
                  sRef ref = uentry_getSref (arg);
-
+                 
                  if (uentry_isReturned (arg) 
                      || sRef_isOnly (ref) 
                      || sRef_isExposed (ref)
@@ -294,7 +319,7 @@ checkRefGlobParam (sRef base, /*@notnull@*/ exprNode e,
          else if (sRef_isAnyParam (base) && !(sRef_isOnly (base)))
            {
              uentryList params = context_getParams ();
-             int paramno = sRef_getParam (base);
+             int paramno = usymId_toInt (sRef_getParam (base));
              
              if (paramno < uentryList_size (params))
                {
@@ -913,17 +938,14 @@ void exprNode_checkFunctionBody (exprNode body)
 /*drl modified */
 
 
-void exprNode_checkFunction (/*@unused@*/ uentry ue, /*@only@*/ exprNode fcnBody)
+void exprNode_checkFunction (/*@unused@*/ uentry ue, /*@only@*/ exprNode body)
 {
   constraintList c, t, post;
   constraintList c2, fix;
   constraintList implicitFcnConstraints;
-
-  /*@owned@*/ exprNode body;
-
   context_enterInnerContext ();
 
-  body = fcnBody;
+  llassert (exprNode_isDefined (body));
 
   /*
     if we're not going to be printing any errors for buffer overflows
@@ -938,8 +960,10 @@ void exprNode_checkFunction (/*@unused@*/ uentry ue, /*@only@*/ exprNode fcnBody
       /* check if errors will printed */
       if (!(context_getFlag(FLG_DEBUGFUNCTIONCONSTRAINT) ||
            context_getFlag(FLG_BOUNDSWRITE) ||
-           context_getFlag(FLG_BOUNDSREAD) ||
-           context_getFlag(FLG_CHECKPOST)))
+           context_getFlag(FLG_BOUNDSREAD)  ||
+           context_getFlag(FLG_LIKELYBOUNDSWRITE) ||
+           context_getFlag(FLG_LIKELYBOUNDSREAD)  ||
+           context_getFlag(FLG_CHECKPOST) ))
        {
          exprNode_free (body);
          context_exitInnerPlain();
@@ -948,7 +972,8 @@ void exprNode_checkFunction (/*@unused@*/ uentry ue, /*@only@*/ exprNode fcnBody
        }
     }
   
-  exprNode_generateConstraints (body);
+  exprNode_generateConstraints (body); /* evans 2002-03-02: this should not be declared to take a
+                                         dependent... fix it! */
   
   c =   uentry_getFcnPreconditions (ue);
   DPRINTF(("function constraints\n"));
This page took 0.04387 seconds and 4 git commands to generate.