** 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
*/
/*
* or, if not set "." will be used.
*/
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
# include "llbasic.h"
# ifndef NOLCL
static void context_exitClausePlain (void) /*@modifies gc@*/ ;
static void context_setJustPopped (void) /*@modifies gc.justpopped@*/ ;
static void context_setValue (flagcode p_flag, int p_val) /*@modifies gc.flags@*/ ;
-static void context_setFlag (flagcode p_f, bool p_b)
+static void context_setFlag (flagcode p_f, bool p_b, fileloc p_loc)
/*@modifies gc.flags@*/ ;
static void
- context_setFlagAux (flagcode p_f, bool p_b, bool p_inFile, bool p_isRestore)
+ context_setFlagAux (flagcode p_f, bool p_b, bool p_inFile,
+ bool p_isRestore, fileloc p_loc)
/*@modifies gc.flags@*/ ;
-static void context_restoreFlag (flagcode p_f) /*@modifies gc.flags@*/ ;
+static void context_restoreFlag (flagcode p_f, fileloc p_loc)
+ /*@modifies gc.flags@*/ ;
/*@+enumindex@*/
}
void
-context_addComment (/*@only@*/ cstring def)
+context_addComment (/*@only@*/ cstring def, fileloc loc)
{
- DPRINTF (("macro comment: %s", def));
- macrocache_addComment (gc.mc, fileloc_copy (g_currentloc), def);
+ macrocache_addComment (gc.mc, fileloc_copy (loc), def);
}
/*
}
void
-context_enterSuppressRegion (void)
+context_enterSuppressRegion (fileloc loc)
{
if (gc.insuppressregion)
{
gc.insuppressregion = FALSE; /* get this msg! */
llmsg (message
("%q: New ignore errors region entered while in ignore errors region",
- fileloc_unparse (g_currentloc)));
+ fileloc_unparse (loc)));
}
gc.insuppressregion = TRUE;
- flagMarkerList_add (gc.markers, flagMarker_createIgnoreOn (g_currentloc));
+ (void) flagMarkerList_add (gc.markers, flagMarker_createIgnoreOn (loc));
}
static void
-context_addFlagMarker (flagcode code, ynm set)
+context_addFlagMarker (flagcode code, ynm set, fileloc loc)
{
- flagMarkerList_add (gc.markers,
- flagMarker_createLocalSet (code, set, g_currentloc));
+ (void) flagMarkerList_add (gc.markers,
+ flagMarker_createLocalSet (code, set, loc));
}
void
-context_enterSuppressLine (int count)
+context_enterSuppressLine (int count, fileloc loc)
{
- fileloc nextline = fileloc_copy (g_currentloc);
+ if (context_processingMacros ())
+ {
+ return;
+ }
- flagMarkerList_add (gc.markers,
- flagMarker_createIgnoreCount (count, g_currentloc));
+ if (flagMarkerList_add
+ (gc.markers,
+ flagMarker_createIgnoreCount (count, loc)))
+ {
+ fileloc nextline = fileloc_copy (loc);
+ fileloc_nextLine (nextline);
+ fileloc_setColumn (nextline, 0);
- fileloc_nextLine (nextline);
- flagMarkerList_add (gc.markers,
- flagMarker_createIgnoreOff (nextline));
- fileloc_free (nextline);
+ check (flagMarkerList_add (gc.markers,
+ flagMarker_createIgnoreOff (nextline)));
+ fileloc_free (nextline);
+ }
}
void context_checkSuppressCounts (void)
}
void
-context_exitSuppressRegion (void)
+context_exitSuppressRegion (fileloc loc)
{
if (!gc.insuppressregion)
{
- llerrorlit (FLG_SYNTAX,
- "End ignore errors in region while not ignoring errors");
+ voptgenerror
+ (FLG_SYNTAX,
+ message ("End ignore errors in region while not ignoring errors"),
+ loc);
}
-
- gc.insuppressregion = FALSE;
- flagMarkerList_add (gc.markers, flagMarker_createIgnoreOff (g_currentloc));
+
+ gc.insuppressregion = FALSE;
+ (void) flagMarkerList_add (gc.markers, flagMarker_createIgnoreOff (loc));
}
void
if (gc.kind != CX_LCLLIB)
{
cstring lclname =
- fileLib_withoutExtension (fileName (currentFile ()), LCL_EXTENSION);
+ fileLib_withoutExtension (fileTable_fileName (currentFile ()), LCL_EXTENSION);
addModuleAccess (fileLib_removePath (lclname), gc.facct);
cstring_free (lclname);
void
context_resetModeFlags (void)
-{
-
+{
allFlagCodes (code)
{
if (flagcode_isModeFlag (code))
{
- context_setFlag (code, FALSE);
+ context_setFlag (code, FALSE, g_currentloc);
}
} end_allFlagCodes;
}
gc.flags[FLG_ZEROPTR] = TRUE;
gc.flags[FLG_NUMLITERAL] = TRUE;
gc.flags[FLG_DUPLICATEQUALS] = TRUE;
- gc.flags[FLG_SKIPANSIHEADERS] = TRUE;
+ gc.flags[FLG_SKIPISOHEADERS] = TRUE;
gc.flags[FLG_SKIPPOSIXHEADERS] = TRUE;
gc.flags[FLG_SYSTEMDIREXPAND] = TRUE;
gc.flags[FLG_UNRECOGCOMMENTS] = TRUE;
gc.flags[FLG_GNUEXTENSIONS] = TRUE;
+ /*
+ Changed for 3.0.0.19
+ */
+
+ /* commenting ou until some output issues are fixed */
+ /* gc.flags[FLG_ORCONSTRAINT] = TRUE;*/
+
+ gc.flags[FLG_CONSTRAINTLOCATION] = TRUE;
+
+ /*drl 1/18/2002*/
+ gc.flags[FLG_WARNSYSFILES] = TRUE;
+
/*
** On by default for Win32, but not Unix (to support MS/VC++ error message format).
*/
if (!flagcode_isModeFlag (modeflags[i])) \
{ llbug (message ("not a mode flag: %s", \
flagcode_unparse (modeflags[i]))); } \
- else { context_setFlag (modeflags[i], TRUE); } i++; }}
+ else { context_setFlag (modeflags[i], TRUE, g_currentloc); } i++; }}
static void context_setModeAux (cstring p_s, bool p_warn) ;
FLG_UNCHECKEDGLOBALIAS,
FLG_FORMATCONST,
FLG_STRINGLITNOROOM,
+ FLG_STRINGLITNOROOMFINALNULL,
FLG_STRINGLITSMALLER,
FLG_EXITARG, FLG_PTRNUMCOMPARE,
FLG_BOOLCOMPARE, FLG_UNSIGNEDCOMPARE,
FLG_LOOPLOOPBREAK, FLG_SWITCHLOOPBREAK, FLG_MODGLOBS,
FLG_CHECKSTRICTGLOBALS, FLG_IMPCHECKEDSPECGLOBALS,
FLG_MACROMATCHNAME, FLG_WARNLINTCOMMENTS,
- FLG_INCLUDENEST, FLG_ANSIRESERVED, FLG_CPPNAMES,
+ FLG_INCLUDENEST, FLG_ISORESERVED, FLG_CPPNAMES,
FLG_NOPARAMS, FLG_IFEMPTY, FLG_WHILEEMPTY, FLG_REALCOMPARE,
FLG_BOOLOPS, FLG_SHIFTNEGATIVE,
FLG_SHIFTIMPLEMENTATION,
FLG_MACROMATCHNAME,
FLG_FORMATCONST,
FLG_STRINGLITNOROOM,
+ FLG_STRINGLITNOROOMFINALNULL,
FLG_STRINGLITSMALLER,
FLG_STATETRANSFER, FLG_STATEMERGE,
FLG_MACROUNDEF, FLG_MUTREP, FLG_MUSTMOD,
FLG_PTRNUMCOMPARE,
FLG_BOOLCOMPARE, FLG_UNSIGNEDCOMPARE,
FLG_NOEFFECT, FLG_RETVALINT, FLG_RETVALBOOL, FLG_RETVALOTHER,
- FLG_ANSIRESERVED, FLG_ANSIRESERVEDLOCAL, FLG_CPPNAMES,
+ FLG_ISORESERVED, FLG_ISORESERVEDLOCAL, FLG_CPPNAMES,
FLG_RETVALBOOL, FLG_RETVALINT, FLG_SPECUNDEF,
FLG_DECLUNDEF, FLG_STRICTOPS, FLG_INCONDEFS,
FLG_MISPLACEDSHAREQUAL, FLG_REDUNDANTSHAREQUAL,
FLG_IMPCHECKEDSTRICTSPECGLOBALS,
FLG_IMPCHECKMODINTERNALS,
FLG_WARNMISSINGGLOBALS, FLG_WARNMISSINGGLOBALSNOGLOBS,
- FLG_WARNLINTCOMMENTS, FLG_ANSIRESERVEDLOCAL,
+ FLG_WARNLINTCOMMENTS, FLG_ISORESERVEDLOCAL,
FLG_INCLUDENEST, FLG_STRINGLITERALLEN,
FLG_NUMSTRUCTFIELDS, FLG_NUMENUMMEMBERS,
FLG_CONTROLNESTDEPTH,
void context_enterSwitch (exprNode e)
{
-
+ DPRINTF (("Enter switch: %s", exprNode_unparse (e)));
usymtab_switchBranch (e);
context_enterCondClauseAux (SWITCHCLAUSE);
}
void context_exitSwitch (exprNode e, bool allpaths)
{
- usymtab_exitSwitch (e, allpaths);
+ usymtab_exitSwitch (e, allpaths);
while (clause_isCase (clauseStack_top (gc.clauses)))
{
sRef_enterFunctionScope ();
}
+bool context_inOldSytleScope(void)
+{
+ if (gc.kind == CX_OLDSTYLESCOPE)
+ return TRUE;
+ else
+ return FALSE;
+}
+
void
context_enterOldStyleScope (void)
{
{
llerror_flagWarning (message ("Value for %s must be a positive "
- "number (given %d)",
- flagcode_unparse (flag), val));
+ "number (given %d)",
+ flagcode_unparse (flag), val));
return;
}
if (flag == FLG_LINELEN && val < MINLINELEN)
{
llerror_flagWarning (message ("Value for %s must be at least %d (given %d)",
- flagcode_unparse (flag),
- MINLINELEN, val));
+ flagcode_unparse (flag),
+ MINLINELEN, val));
val = MINLINELEN;
}
break;
{
int n = cstring_length (tval) - 1;
- while (isspace ((int) cstring_getChar (tval, n)))
+ while (isspace ((int) cstring_getChar (tval, size_fromInt (n))))
{
n--;
}
- if (cstring_getChar (tval, n) != '\"')
+ if (cstring_getChar (tval, size_fromInt (n)) != '\"')
{
llerror_flagWarning (message ("Setting -systemdirs to string with unmatching quotes: %s", val));
}
else
{
cstring otval = tval;
- tval = cstring_prefix (tval, n);
+ tval = cstring_prefix (tval, size_fromInt (n));
cstring_free (otval);
}
}
if (fileId_isValid (currentFile ()))
{
fileloc lastfl;
- cstring cbase = fileLib_removePathFree (fileLib_removeAnyExtension (fileName (currentFile ())));
+ cstring cbase = fileLib_removePathFree (fileLib_removeAnyExtension (fileTable_fileName (currentFile ())));
gc.inmacrocache = TRUE;
{
if (gc.flags[FLG_EXPORTHEADER])
{
- llerror_flagWarning (cstring_makeLiteral
- ("setting +neverinclude after +exportheader. "
- "Turning off exportheader, since headers are not checked "
- "when +neverinclude is used."));
+ llerror_flagWarning
+ (cstring_makeLiteral
+ ("setting +neverinclude after +exportheader. "
+ "Turning off exportheader, since headers are not checked "
+ "when +neverinclude is used."));
gc.flags[FLG_EXPORTHEADER] = FALSE;
}
{
if (gc.flags[FLG_NEVERINCLUDE])
{
- llerror_flagWarning (cstring_makeLiteral
- ("setting +exportheader after +neverinclude. "
- "Not setting exportheader, since headers are not checked "
- "when +neverinclude is used."));
+ llerror_flagWarning
+ (cstring_makeLiteral
+ ("setting +exportheader after +neverinclude. "
+ "Not setting exportheader, since headers are not checked "
+ "when +neverinclude is used."));
gc.flags[FLG_EXPORTHEADER] = FALSE;
return;
}
&& !flagcode_isIdemFlag (f)
&& !flagcode_hasArgument (f))
{
- llerror_flagWarning (message ("setting %s%s redundant with current value",
- cstring_makeLiteralTemp (b ? "+" : "-"),
- flagcode_unparse (f)));
+ llerror_flagWarning
+ (message ("setting %s%s redundant with current value",
+ cstring_makeLiteralTemp (b ? "+" : "-"),
+ flagcode_unparse (f)));
}
}
{
if (!context_getFlag (FLG_WARNUSE))
{
- llerror_flagWarning (message ("flag +%s is canceled by -warnuse",
- flagcode_unparse (f)));
-
+ llerror_flagWarning
+ (message ("flag +%s is canceled by -warnuse",
+ flagcode_unparse (f)));
}
}
if (gc.library != FLG_ANSILIB
&& gc.library != f)
{
- llerror_flagWarning (message ("selecting library %s after library %s was "
- "selected (only one library may be used)",
- flagcode_unparse (f),
- flagcode_unparse (gc.library)));
+ llerror_flagWarning
+ (message ("selecting library %s after library %s was "
+ "selected (only one library may be used)",
+ flagcode_unparse (f),
+ flagcode_unparse (gc.library)));
}
-
+
if (f == FLG_UNIXLIB)
{
if (context_getFlag (FLG_WARNUNIXLIB))
{
- llerror_flagWarning (cstring_makeLiteral
- ("selecting unix library. Unix library is "
- "ad hoc addition to POSIX library. Recommend "
- "use +posixlib to select POSIX library instead. "
- "Use -warnunixlib to suppress this message."));
+ llerror_flagWarning
+ (cstring_makeLiteral
+ ("selecting unix library. Unix library is "
+ "ad hoc addition to POSIX library. Recommend "
+ "use +posixlib to select POSIX library instead. "
+ "Use -warnunixlib to suppress this message."));
}
}
gc.library = f;
}
-
+
if (flagcode_isNameChecksFlag (f) && b && !context_maybeSet (FLG_NAMECHECKS))
{
- llerror_flagWarning (message
- ("setting +%s will not produce warnings with -namechecks. Must set +namechecks also.",
- flagcode_unparse (f)));
+ llerror_flagWarning
+ (message
+ ("setting +%s will not produce warnings with -namechecks. "
+ "Must set +namechecks also.",
+ flagcode_unparse (f)));
}
-
+
gc.setGlobally[f] = TRUE;
- context_setFlag (f, b);
+ context_setFlag (f, b, g_currentloc);
}
void
-context_fileSetFlag (flagcode f, ynm set)
+context_fileSetFlag (flagcode f, ynm set, fileloc loc)
{
if (!gc.savedFlags)
{
if (ynm_isOff (set))
{
- context_setFlagAux (f, FALSE, TRUE, FALSE);
+ context_setFlagAux (f, FALSE, TRUE, FALSE, loc);
}
else if (ynm_isOn (set))
{
- context_setFlagAux (f, TRUE, TRUE, FALSE);
+ context_setFlagAux (f, TRUE, TRUE, FALSE, loc);
gc.setLocally[f] = TRUE;
}
else
{
- context_restoreFlag (f);
+ context_restoreFlag (f, loc);
}
}
static void
-context_restoreFlag (flagcode f)
+context_restoreFlag (flagcode f, fileloc loc)
{
-
if (!gc.savedFlags)
{
voptgenerror
message ("Attempt to restore flag %s when no file scope flags "
"have been set.",
flagcode_unparse (f)),
- g_currentloc);
+ loc);
}
else
{
- context_addFlagMarker (f, MAYBE);
- context_setFlagAux (f, gc.saveflags[f], FALSE, TRUE);
+ context_addFlagMarker (f, MAYBE, loc);
+ context_setFlagAux (f, gc.saveflags[f], FALSE, TRUE, loc);
}
}
static void
-context_setFlag (flagcode f, bool b)
+context_setFlag (flagcode f, bool b, fileloc loc)
{
- context_setFlagAux (f, b, FALSE, FALSE);
+ context_setFlagAux (f, b, FALSE, FALSE, loc);
}
void
/*@notfunction@*/
# define DOSET(ff,b) \
do { if (inFile) { gc.setLocally[ff] = TRUE; \
- context_addFlagMarker (ff, ynm_fromBool (b)); } \
+ context_addFlagMarker (ff, ynm_fromBool (b), loc); } \
DPRINTF (("set flag: %s / %s", flagcode_unparse (ff), bool_unparse (b))); \
gc.flags[ff] = b; } while (FALSE)
static void
context_setFlagAux (flagcode f, bool b, bool inFile,
- /*@unused@*/ bool isRestore)
+ /*@unused@*/ bool isRestore, fileloc loc)
{
DPRINTF (("Set flag: %s / %s", flagcode_unparse (f), bool_unparse (b)));
+/*drl 12/30/01 these are some ugly functions that were added to facilitate struct annotations */
+
+
+/*drl added */
+static ctype lastStruct;
+
+ctype context_setLastStruct (/*@returned@*/ ctype s) /*@globals lastStruct@*/
+{
+ lastStruct = s;
+ return s;
+}
+
+ctype context_getLastStruct (/*@returned@*/ /*ctype s*/) /*@globals lastStruct@*/
+{
+ return lastStruct;
+}
+
+
+/*@unused@*/ static int sInfoNum = 0;
+
+
+struct getUe {
+ /*@unused@*/ uentry ue;
+ /*@unused@*/ sRef s;
+};
+
+struct sInfo {
+ /*@unused@*/ ctype ct;
+ /*@unused@*/ constraintList inv;
+ /*@unused@*/ int ngetUe;
+ /*@unused@*/ struct getUe * t ;
+};
+
+
+static struct sInfo globalStructInfo;
+
+
+/*drl 1/6/2001: I didn't think these functions were solid enough to include in the
+ stable release of splint. I coomented them out so that they won't break anything
+ but didn't delete them because they will be fixed and included later
+*/
+
+/*
+void setGlobalStructInfo(ctype ct, constraintList list)
+{
+ int i;
+ uentryList f;
+
+ f = ctype_getFields (ct);
+
+ if (constraintList_isDefined(list) )
+ {
+ globalStructInfo.ct = ct;
+ globalStructInfo.inv = list;
+
+ globalStructInfo.ngetUe = 0;
+
+ / *abstraction violation fix it * /
+ globalStructInfo.t = dmalloc(f->nelements * sizeof(struct getUe) );
+
+ globalStructInfo.ngetUe = f->nelements;
+
+ i = 0;
+
+ uentryList_elements(f, ue)
+ {
+ globalStructInfo.t[i].ue = ue;
+ globalStructInfo.t[i].s = uentry_getSref(ue);
+ TPRINTF(( message(" setGlobalStructInfo:: adding ue=%s and sRef=%s",
+ uentry_unparse(ue), sRef_unparse( uentry_getSref(ue) )
+ )
+ ));
+ i++;
+ }
+ end_uentryList_elements;
+ }
+}
+
+*/
+
+bool hasInvariants (ctype ct) /*@*/
+{
+ if ( ctype_sameName(globalStructInfo.ct, ct) )
+
+ return TRUE;
+
+ else
+
+ return FALSE;
+
+}
+
+/*drl 1/6/2001: I didn't think these functions were solid enough to include in the
+ stable release of splint. I coomented them out so that they won't break anything
+ but didn't delete them because they will be fixed and included later
+*/
+
+/*
+constraintList getInvariants (ctype ct)
+{
+
+ llassert(hasInvariants(ct) );
+
+ return globalStructInfo.inv;
+}
+*/
+
+/*
+static int getSref (ctype ct, sRef s)
+{
+ int i;
+
+ i = 0;
+
+ / *
+ DEBUGGIN INFO
+
+ fprintf(stderr, "getSref: ct = %s (%x)\n", ctype_unparse(ct), ct );
+
+ fprintf(stderr,"getSref: s = (%s) %X \n", sRef_unparse(s), s);
+ * /
+
+ while (i < globalStructInfo.ngetUe)
+ {
+ DPRINTF(( message(" getSref:: comparing ue=%s and sRef=%s",
+ uentry_unparse(globalStructInfo.t[i].ue),
+ sRef_unparse(globalStructInfo.t[i].s)
+ )
+ ));
+
+ / *
+ fprintf (stderr, " globalStructInfo.t[i].s = %x\n ",
+ globalStructInfo.t[i].s );
+ * /
+
+ if (sRef_same(globalStructInfo.t[i].s,s) )
+ return i;
+
+ i++;
+ }
+ return -1;
+}
+
+
+sRef fixSref (ctype ct, sRef base, sRef fix)
+{
+ int index;
+ uentry ue;
+ cstring name;
+ index = getSref(ct, fix);
+
+ if (index < 0)
+ return fix;
+
+ ue = globalStructInfo.t[index].ue;
+ name = uentry_getName(ue);
+ fix = sRef_buildField(base, name );
+ cstring_free(name);
+ return fix;
+}
+
+*/