/*
** 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"
**
*/
+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;
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)
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))
{
/*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
/* 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();
}
}
- 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"));