/*
-** LCLint - annotation-assisted static program checker
-** Copyright (C) 1994-2001 University of Virginia,
+** Splint - annotation-assisted static program checker
+** 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 more information: http://lclint.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
*/
/*
** mtDeclarationNode.c
*/
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
# include "basic.h"
-# include "mtgrammar.h"
extern mtDeclarationNode mtDeclarationNode_create (mttok name, mtDeclarationPieces pieces) /*@*/
{
metaStateInfo msinfo;
int nvalues;
+ cstring defaultMergeMessage =
+ cstring_makeLiteralTemp ("Incompatible state merge (default behavior)");
+
pieces = node->pieces;
/*
mvals = mtValuesNode_getValues (mtv);
}
- /*@-usedef@*/ /*@i34 lclint should figure this out... */
+ /*@-usedef@*/ /* splint should figure this out... */
nvalues = cstringList_size (mvals);
/*@=usedef@*/
} end_mtLoseReferenceList_elements ;
}
- /*@-usedef@*/
- DPRINTF (("metastate: %s", metaStateInfo_unparse (msinfo)));
- /*@=usedef@*/
-
tmerge = stateCombinationTable_create (nvalues);
/* Default merge is to make all incompatible mergers errors. */
if (i != j)
{
stateCombinationTable_set
- (tmerge, i, j, metaState_error,
- cstring_makeLiteral ("Incompatible state merge (default behavior)"));
+ (tmerge, i, j, metaState_error, cstring_copy (defaultMergeMessage));
}
}
}
{
for (j = low2index; j <= high2index; j++)
{
- /*@i32 check for multiple definitions! */
+ /* Need to add checks for multiple definitions! */
if (mtTransferAction_isError (taction))
{
}
}
}
+
+ /*
+ ** Unless otherwise indicated, merging is symmetric:
+ */
+
+ for (i = low1index; i <= high1index; i++)
+ {
+ for (j = low2index; j <= high2index; j++)
+ {
+ cstring msg;
+
+ if (stateCombinationTable_lookup (tmerge, j, i, &msg) == metaState_error)
+ {
+ if (cstring_equal (msg, defaultMergeMessage))
+ {
+ /* Override the default action */
+ if (mtTransferAction_isError (taction))
+ {
+ stateCombinationTable_update
+ (tmerge,
+ j, i,
+ vindex,
+ cstring_copy (mtTransferAction_getMessage (taction)));
+ }
+ else
+ {
+ stateCombinationTable_update
+ (tmerge,
+ j, i,
+ vindex,
+ cstring_undefined);
+ }
+ }
+ }
+ }
+ }
} end_mtMergeClauseList_elements ;
}
if (cstringList_contains (mvals, mvalue))
{
int vindex = cstringList_getIndex (mvals, mvalue);
+ mtContextKind mkind;
if (mtContextNode_isReference (mcontext))
{
- if (metaStateInfo_getDefaultRefValue (msinfo) != stateValue_error)
- {
- voptgenerror
- (FLG_SYNTAX,
- message ("Duplicate defaults declaration for context %q: %q",
- mtContextNode_unparse (mcontext),
- mtDefaultsDecl_unparse (mdecl)),
- mtDefaultsDecl_getLoc (mdecl));
- }
- else
- {
- metaStateInfo_setDefaultRefValue (msinfo, vindex);
- }
+ mkind = MTC_REFERENCE;
}
else if (mtContextNode_isParameter (mcontext))
{
- if (metaStateInfo_getDefaultParamValue (msinfo) != stateValue_error)
- {
- voptgenerror
- (FLG_SYNTAX,
- message ("Duplicate defaults declaration for context %q: %q",
- mtContextNode_unparse (mcontext),
- mtDefaultsDecl_unparse (mdecl)),
- mtDefaultsDecl_getLoc (mdecl));
- }
- else
- {
- metaStateInfo_setDefaultParamValue (msinfo, vindex);
- }
+ mkind = MTC_PARAM;
}
else if (mtContextNode_isResult (mcontext))
{
- if (metaStateInfo_getDefaultResultValue (msinfo) != stateValue_error)
- {
- voptgenerror
- (FLG_SYNTAX,
- message ("Duplicate defaults declaration for context %q: %q",
- mtContextNode_unparse (mcontext),
- mtDefaultsDecl_unparse (mdecl)),
- mtDefaultsDecl_getLoc (mdecl));
- }
- else
- {
- metaStateInfo_setDefaultResultValue (msinfo, vindex);
- }
+ mkind = MTC_RESULT;
+ }
+ else if (mtContextNode_isLiteral (mcontext))
+ {
+ mkind = MTC_LITERAL;
+ }
+ else if (mtContextNode_isNull (mcontext))
+ {
+ mkind = MTC_NULL;
}
else
{
+ DPRINTF (("Bad: %s", mtContextNode_unparse (mcontext)));
BADBRANCH;
}
+
+ if (metaStateInfo_getDefaultValueContext (msinfo, mkind) != stateValue_error)
+ {
+ voptgenerror
+ (FLG_SYNTAX,
+ message ("Duplicate defaults declaration for context %q: %q",
+ mtContextNode_unparse (mcontext),
+ mtDefaultsDecl_unparse (mdecl)),
+ mtDefaultsDecl_getLoc (mdecl));
+ }
+ else
+ {
+ metaStateInfo_setDefaultValueContext (msinfo, mkind, vindex);
+ }
}
else
{