/*
** 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"
{
; /* 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 */
}
else
{
llassert (transferType == TT_DOASSIGN
+ || transferType == TT_FIELDASSIGN /* evans 2002-02-05: no warnings for local fields */
|| transferType == TT_GLOBINIT
|| transferType == TT_LEAVETRANS);
}
{
if (stateClause_isGlobal (cl))
{
- ; /*@i32@*/
+ ;
}
else if (stateClause_setsMetaState (cl))
{
exprNode_loc (fexp)))
{
sRef_showAliasInfo (sr);
- /*@i32@*/
}
}
}
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);
sRef_clearDerived (base);
sRef_setDefined (base, exprNode_loc (fexp));
usymtab_clearAlias (base);
- sRef_setNullUnknown (base, exprNode_loc (fexp));
+ /* evans 2004-07-31: Don't change state of constants! */
+ if (!sRef_isConst (base)) {
+ sRef_setNullUnknown (base, exprNode_loc (fexp));
+ }
}
}
if (ctype_isSU (st) && ctype_isRealSU (sRef_getType (slhs))
&& ctype_match (sRef_getType (slhs), st))
{
- if (tt == TT_DOASSIGN && sRef_isStateDefined (srhs))
+ if ((tt == TT_DOASSIGN || tt == TT_FIELDASSIGN) && sRef_isStateDefined (srhs))
{
sRef_setDefinedComplete (slhs, loc);
}
if (sRef_isLocalVar (slhs)
&& sRef_isFileOrGlobalScope (sRef_getRootBase (srhs)))
{
+ DPRINTF (("Global scope!"));
sRef_setDependent (slhs, exprNode_loc (lhs));
}
- else
- {
- if (ctype_isUnion (st))
- {
- sRef_setDefState (slhs, sRef_getDefState (srhs),
- exprNode_loc (lhs));
+ }
- sRefSet_realElements (sRef_derivedFields (srhs), sr)
- {
- if (sRef_isField (sr))
- {
- cstring fieldname = sRef_getField (sr);
- sRef lfld = sRef_makeField (slhs, fieldname);
+ /*
+ ** evans 2003-07-10: should always copy the fields!
+ */
- (void) checkTransfer (rhs, sr, lhs, lfld,
- exprNode_undefined,
- exprNode_loc (lhs), tt);
- }
- } end_sRefSet_realElements ;
- }
- else
+ if (ctype_isUnion (st))
+ {
+ sRef_setDefState (slhs, sRef_getDefState (srhs),
+ exprNode_loc (lhs));
+
+ sRefSet_realElements (sRef_derivedFields (srhs), sr)
+ {
+ if (sRef_isField (sr))
{
- uentryList fields = ctype_getFields (st);
+ cstring fieldname = sRef_getField (sr);
+ sRef lfld = sRef_makeField (slhs, fieldname);
- uentryList_elements (fields, field)
- {
- sRef rfld = sRef_makeField (srhs, uentry_rawName (field));
- sRef lfld = sRef_makeField (slhs, uentry_rawName (field));
- (void) checkTransfer (rhs, rfld, lhs, lfld,
- exprNode_undefined,
- exprNode_loc (lhs), tt);
- } end_uentryList_elements ;
- }
-
- if (sRef_isOnly (srhs))
- {
- sRef_setKeptComplete (srhs, loc);
+ (void) checkTransfer (rhs, sr, lhs, lfld,
+ exprNode_undefined,
+ exprNode_loc (lhs), tt);
}
- }
+ } end_sRefSet_realElements ;
+ }
+ else
+ {
+ uentryList fields = ctype_getFields (st);
+
+ uentryList_elements (fields, field)
+ {
+ sRef rfld = sRef_makeField (srhs, uentry_rawName (field));
+ sRef lfld = sRef_makeField (slhs, uentry_rawName (field));
+ DPRINTF (("Transfer field: %s := %s",
+ sRef_unparse (lfld), sRef_unparse (rfld)));
+ (void) checkTransfer (rhs, rfld, lhs, lfld,
+ exprNode_undefined,
+ exprNode_loc (lhs), tt);
+ } end_uentryList_elements ;
+ }
+
+ if (sRef_isOnly (srhs))
+ {
+ sRef_setKeptComplete (srhs, loc);
}
}
}
if (ctype_isRealSU (sRef_getType (srhs)))
{
+ DPRINTF (("Check struct transfer: %s := %s", exprNode_unparse (lhs),
+ exprNode_unparse (rhs)));
checkStructTransfer (lhs, slhs, rhs, srhs, exprNode_loc (lhs), TT_FIELDASSIGN);
}
else
alkind tkind = sRef_getAliasKind (tref);
ctype ttyp = ctype_realType (sRef_getType (tref));
+ DPRINTF (("Null transfer: %s => %s", sRef_unparseFull (fref), sRef_unparseFull (tref)));
+
if (ctype_isUnknown (ttyp))
{
ttyp = exprNode_getType (texp);
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),
}
}
}
+
+ DPRINTF (("Transfer ==> %s", sRef_unparseFull (tref)));
}
/*
bool isfcnpass = (transferType == TT_FCNPASS);
bool isfcnreturn = (transferType == TT_FCNRETURN);
+ DPRINTF (("Check transfer: %s [%s] => %s [%s]",
+ exprNode_unparse (fexp),
+ sRef_unparseFull (fref),
+ exprNode_unparse (texp),
+ sRef_unparseFull (tref)));
+
setCodePoint ();
if (!ffix && !tfix)
setCodePoint ();
checkTransferNullAux (fref, fexp, ffix, tref, texp, tfix,
loc, transferType);
+ DPRINTF (("Transfer ==> %s", sRef_unparseFull (fref)));
}
if (isassign)
setCodePoint ();
checkTransferAssignAux (fref, fexp, ffix, tref, texp, tfix,
loc, transferType);
+ DPRINTF (("Transfer ==> %s", sRef_unparseFull (fref)));
}
/*
;
}
+ DPRINTF (("Transfer ==> %s", sRef_unparseFull (fref)));
+ DPRINTF (("Transfer ==> %s", sRef_unparseFull (tref)));
setCodePoint ();
}
}
else
{
- /*@i#!@!!@*/
DPRINTF (("Cannot find meta state for: %s / to: %s / %s", sRef_unparseFull (fref),
sRef_unparseFull (tref),
fkey));
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);
}
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),
{
if (nval == stateValue_error)
{
- /*@i32 print extra info for assignments@*/
-
if (optgenerror
(FLG_STATETRANSFER,
message
{
bool gotone = FALSE;
sRefSet ab = usymtab_aliasedBy (sr); /* yes, really mean aliasedBy */
-
+
+ DPRINTF (("Aliased by: %s", sRefSet_unparse (ab)));
+
/*
** if there is a local variable that aliases sr, then there is no
** error. Make the local an only.