/*
** 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 splint: splint@cs.virginia.edu
-** To report a bug: splint-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
*/
/*
# include "splintMacros.nf"
# include "llbasic.h"
-# ifndef NOLCL
# include "usymtab_interface.h"
-# endif
-
# include "exprChecks.h"
# include "filelocStack.h"
-# include "fileIdList.h"
# include "llmain.h"
# include "intSet.h"
# include "osd.h"
typedef struct
{
cstring file;
- typeIdSet daccess ;
+ typeIdSet daccess;
} maccesst;
typedef enum {
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
gc.kind = CX_GLOBAL;
}
-# ifndef NOLCL
void
context_enterLCLfile (void)
{
gc.kind = CX_LCL;
gc.facct = typeIdSet_emptySet ();
}
-# endif
static void
addModuleAccess (/*@only@*/ cstring fname, typeIdSet mods)
addModuleAccess (cstring_copy (fname), typeIdSet_single (t));
}
-# ifndef NOLCL
void
context_exitLCLfile (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);
gc.kind = CX_GLOBAL;
gc.facct = typeIdSet_emptySet ();
}
-# endif
void
context_dumpModuleAccess (FILE *fout)
void
context_resetModeFlags (void)
-{
-
+{
allFlagCodes (code)
{
if (flagcode_isModeFlag (code))
{
- context_setFlag (code, FALSE);
+ context_setFlag (code, FALSE, g_currentloc);
}
} end_allFlagCodes;
}
val = DEFAULT_LINELEN; break;
case FLG_INDENTSPACES:
val = DEFAULT_INDENTSPACES; break;
+ case FLG_LOCINDENTSPACES:
+ val = DEFAULT_LOCINDENTSPACES; break;
case FLG_EXTERNALNAMELEN:
val = ISO99_EXTERNALNAMELEN; break;
case FLG_INTERNALNAMELEN:
default:
break;
} /*@=loopswitchbreak@*/
-
+
context_setString (code, val);
}
else
/*@i34 move this into flags.def */
+ gc.flags[FLG_STREAMOVERWRITE] = TRUE;
+
gc.flags[FLG_OBVIOUSLOOPEXEC] = TRUE;
gc.flags[FLG_MODIFIES] = TRUE;
gc.flags[FLG_NESTCOMMENT] = TRUE;
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_WARNUNIXLIB] = TRUE;
gc.flags[FLG_WARNPOSIX] = TRUE;
gc.flags[FLG_SHOWCOL] = TRUE;
+ gc.flags[FLG_SHOWDEEPHISTORY] = FALSE; /* TRUE; */
gc.flags[FLG_SHOWFUNC] = TRUE;
gc.flags[FLG_SUPCOUNTS] = TRUE;
gc.flags[FLG_HINTS] = TRUE;
gc.flags[FLG_TYPE] = TRUE;
gc.flags[FLG_INCOMPLETETYPE] = TRUE;
gc.flags[FLG_ABSTRACT] = TRUE;
+ gc.flags[FLG_NUMABSTRACT] = TRUE;
gc.flags[FLG_ITERBALANCE] = TRUE;
gc.flags[FLG_ITERYIELD] = TRUE;
gc.flags[FLG_DUPLICATECASES] = TRUE;
/*
Changed for 3.0.0.19
*/
- gc.flags[FLG_ORCONSTRAINT] = TRUE;
+
+ /* 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).
+ ** On by default for Win32, but not Unix
*/
# ifdef WIN32
gc.flags[FLG_PARENFILEFORMAT] = TRUE;
+ gc.flags[FLG_CASEINSENSITIVEFILENAMES] = TRUE;
# endif
}
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) ;
flagcode modeflags[] =
{
FLG_ENUMINT, FLG_MACROMATCHNAME,
- FLG_STRINGLITNOROOM,
+ FLG_STRINGLITNOROOM,
+ FLG_STRINGLITNOROOMFINALNULL,
FLG_MACROUNDEF, FLG_RELAXQUALS,
FLG_USEALLGLOBS, FLG_CHECKSTRICTGLOBALS,
FLG_CHECKSTRICTGLOBALIAS,
FLG_UNSIGNEDCOMPARE,
FLG_PARAMUNUSED, FLG_VARUNUSED, FLG_FUNCUNUSED,
FLG_TYPEUNUSED,
+ FLG_ABSTRACTCOMPARE,
FLG_CONSTUNUSED, FLG_ENUMMEMUNUSED, FLG_FIELDUNUSED,
FLG_PTRNUMCOMPARE, FLG_BOOLCOMPARE, FLG_UNSIGNEDCOMPARE,
- FLG_MUTREP, FLG_NOEFFECT, FLG_IMPTYPE,
+ FLG_MUTREP, FLG_NOEFFECT, FLG_IMPTYPE,
FLG_RETVALOTHER, FLG_RETVALBOOL, FLG_RETVALINT,
FLG_SPECUNDEF, FLG_INCONDEFS, FLG_INCONDEFSLIB, FLG_MISPLACEDSHAREQUAL,
FLG_MATCHFIELDS,
FLG_UNKNOWNTRANS,
FLG_KEEPTRANS,
FLG_IMMEDIATETRANS,
-
+ FLG_NUMABSTRACTCAST,
FLG_EXPORTLOCAL,
FLG_USERELEASED, FLG_ALIASUNIQUE, FLG_MAYALIASUNIQUE,
{
flagcode modeflags[] =
{
- FLG_BOOLINT, FLG_CHARINT, FLG_FLOATDOUBLE,
+ FLG_BOOLINT, FLG_CHARINT, FLG_FLOATDOUBLE, FLG_LONGINT, FLG_SHORTINT,
FLG_ENUMINT, FLG_RELAXQUALS, FLG_FORWARDDECL,
FLG_CHARINDEX, FLG_ABSTVOIDP, FLG_USEALLGLOBS,
FLG_CHARUNSIGNEDCHAR,
FLG_PREDBOOLOTHERS,
+ FLG_NUMABSTRACTLIT,
FLG_VARUNUSED, FLG_FUNCUNUSED,
FLG_TYPEUNUSED,
FLG_CHECKSTRICTGLOBALS, FLG_MACROMATCHNAME,
FLG_CHARINTLITERAL,
FLG_ZEROBOOL,
FLG_BUFFEROVERFLOWHIGH,
+ FLG_STRINGLITNOROOM,
+ FLG_STRINGLITNOROOMFINALNULL,
INVALID_FLAG
} ;
{
flagcode modeflags[] =
{
- FLG_EXPORTLOCAL, FLG_IMPTYPE,
+ FLG_EXPORTLOCAL, FLG_IMPTYPE,
+ FLG_NUMABSTRACTCAST,
+ FLG_ABSTRACTCOMPARE,
FLG_STATETRANSFER, FLG_STATEMERGE,
FLG_CHECKSTRICTGLOBALIAS,
FLG_CHECKEDGLOBALIAS,
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,
{
flagcode modeflags[] =
{
- FLG_CHECKSTRICTGLOBALIAS,
+ FLG_ABSTRACTCOMPARE,
+ FLG_CHECKSTRICTGLOBALIAS,
+ FLG_NUMABSTRACTCAST,
FLG_CHECKEDGLOBALIAS,
FLG_CHECKMODGLOBALIAS,
FLG_UNCHECKEDGLOBALIAS,
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_inOldStyleScope(void)
+{
+ return (gc.kind == CX_OLDSTYLESCOPE);
+}
+
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;
llassert (index >= 0 && index <= NUMSTRINGFLAGS);
- if (flag == FLG_SYSTEMDIRS)
- {
- llassert (cstring_isDefined (val));
+ DPRINTF (("set string: %s", flagcode_unparse (flag)));
- if (cstring_firstChar (val) == '\"')
- {
- cstring oval = val;
- cstring tval = cstring_copy (cstring_suffix (val, 1));
-
- if (cstring_lastChar (tval) != '\"')
- {
- int n = cstring_length (tval) - 1;
+ switch (flag)
+ {
+ /*
+ case FLG_BOOLTRUE:
+ usymtab_supGlobalEntry
+ (uentry_makeConstantValue (val, ctype_bool,
+ fileloc_getBuiltin (), TRUE,
+ multiVal_makeInt (1)));
+ break;
+ case FLG_BOOLFALSE:
+ usymtab_supGlobalEntry
+ (uentry_makeConstantValue (val, ctype_bool,
+ fileloc_getBuiltin (), FALSE,
+ multiVal_makeInt (0)));
+ break;
+ */
+ case FLG_MESSAGESTREAM:
+ case FLG_WARNINGSTREAM:
+ case FLG_ERRORSTREAM:
+ {
+ if (cstring_isDefined (val))
+ {
+ FILE *fstream;
- while (isspace ((int) cstring_getChar (tval, n)))
- {
- n--;
- }
+ if (osd_fileExists (val))
+ {
+ if (context_getFlag (FLG_STREAMOVERWRITE))
+ {
+ llfatalerror (message
+ ("Output stream file %s would overwrite existing file. "
+ "Use -streamoverwrite if you want to allow this.",
+ val));
+ }
+ }
+
+ fstream = fopen (cstring_toCharsSafe (val), "w");
- if (cstring_getChar (tval, n) != '\"')
- {
- llerror_flagWarning (message ("Setting -systemdirs to string with unmatching quotes: %s", val));
- }
- else
- {
- cstring otval = tval;
- tval = cstring_prefix (tval, n);
- cstring_free (otval);
- }
- }
-
- val = cstring_copy (cstring_clip (tval, cstring_length (tval) - 1));
- DPRINTF (("val = %s", val));
- cstring_free (tval);
- cstring_free (oval);
- }
- }
+ if (fstream == NULL)
+ {
+ llfatalerror (message ("Unable to open output stream file %s for writing",
+ val));
+ }
- if (flag == FLG_TMPDIR)
- {
- llassert (cstring_isDefined (val));
-
- if (cstring_length (val) == 0)
- {
- cstring_free (val);
- val = message (".%s", cstring_makeLiteralTemp (CONNECTSTR));
- }
- else if (cstring_lastChar (val) != CONNECTCHAR)
- {
- val = cstring_appendChar (val, CONNECTCHAR);
- }
- else
- {
- ;
- }
- }
+ /*
+ ** This ensures fstream will be closed on exit.
+ */
+ fileTable_addStreamFile (gc.ftab, fstream, cstring_copy (val));
+
+ switch (flag)
+ {
+ case FLG_MESSAGESTREAM:
+ g_messagestream = fstream;
+ /*@innerbreak@*/ break;
+ case FLG_WARNINGSTREAM:
+ g_warningstream = fstream;
+ /*@innerbreak@*/ break;
+ case FLG_ERRORSTREAM:
+ g_errorstream = fstream;
+ /*@innerbreak@*/ break;
+ BADDEFAULT;
+ }
+ /*@-statetransfer@*/
+ } /*@=statetransfer@*/ /* fstream not closed, but will be on exit */
+ break;
+ }
+ case FLG_SYSTEMDIRS:
+ {
+ llassert (cstring_isDefined (val));
+
+ if (cstring_firstChar (val) == '\"')
+ {
+ cstring oval = val;
+ cstring tval = cstring_copy (cstring_suffix (val, 1));
+
+ if (cstring_lastChar (tval) != '\"')
+ {
+ int n = size_toInt (cstring_length (tval) - 1);
+
+ while (isspace ((int) cstring_getChar (tval, size_fromInt (n))))
+ {
+ 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, size_fromInt (n));
+ cstring_free (otval);
+ }
+ }
+
+ val = cstring_copy (cstring_clip (tval, cstring_length (tval) - 1));
+ DPRINTF (("val = %s", val));
+ cstring_free (tval);
+ cstring_free (oval);
+ }
+
+ break;
+ }
+ case FLG_TMPDIR:
+ {
+ llassert (cstring_isDefined (val));
+
+ if (cstring_length (val) == 0)
+ {
+ cstring_free (val);
+ val = message (".%s", cstring_makeLiteralTemp (CONNECTSTR));
+ }
+ else if (cstring_lastChar (val) != CONNECTCHAR)
+ {
+ val = cstring_appendChar (val, CONNECTCHAR);
+ }
+ else
+ {
+ ;
+ }
+ break;
+ }
+ default:
+ {
+ ; /* Okay not handle everything in this switch */
+ }
+ /*@i523@*/ } /* evans 2002-03-24: splintme reports a spurious (I think) warning here...need to look into it */
+
if (cstring_length (val) >= 1
&& cstring_firstChar (val) == '\"')
{
llerror_flagWarning (message
- ("setting %s to string beginning with \". You probably "
- "don't meant to have the \"'s.",
- flagcode_unparse (flag)));
- }
-
- if (flag == FLG_BOOLTYPE)
- {
-
+ ("Setting %s to string beginning with \". You probably "
+ "don't meant to have the \"'s.",
+ flagcode_unparse (flag)));
}
-
+
gc.strings[index] = val;
}
end_allFlagCodes ;
usymtab_initMod ();
-
context_resetAllFlags ();
assertSet (gc.flags); /* Can't use global in defines */
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;
void
context_userSetFlag (flagcode f, bool b)
{
- DPRINTF (("set flag: %s", flagcode_unparse (f)));
+ DPRINTF (("set flag: %s / %s",
+ flagcode_unparse (f),
+ bool_unparse (context_getFlag (f))));
if (f == FLG_NEVERINCLUDE && b)
{
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)));
- if (f == FLG_USESTDERR)
- {
- if (b) {
- g_msgstream = stderr;
- } else {
- g_msgstream = stdout;
- }
- }
-
/*
** Removed test for special flags.
*/
switch (f)
{
+ case FLG_MESSAGESTREAMSTDOUT:
+ g_messagestream = stdout;
+ break;
+ case FLG_MESSAGESTREAMSTDERR:
+ g_messagestream = stderr;
+ break;
+ case FLG_WARNINGSTREAMSTDOUT:
+ g_warningstream = stdout;
+ break;
+ case FLG_WARNINGSTREAMSTDERR:
+ g_warningstream = stderr;
+ break;
+ case FLG_ERRORSTREAMSTDOUT:
+ g_errorstream = stdout;
+ break;
+ case FLG_ERRORSTREAMSTDERR:
+ g_errorstream = stderr;
+ break;
case FLG_ALLEMPTY:
DOSET (FLG_ALLEMPTY, b);
DOSET (FLG_IFEMPTY, b);
DOSET (FLG_ALLMACROS, b);
DOSET (FLG_FCNMACROS, b);
DOSET (FLG_CONSTMACROS, b);
- break;
+ break;
case FLG_BOUNDS:
DOSET (FLG_BOUNDSREAD, b);
DOSET (FLG_BOUNDSWRITE, b);
+ DOSET (FLG_LIKELYBOUNDSREAD, b);
+ DOSET (FLG_LIKELYBOUNDSWRITE, b);
+ break;
+ case FLG_BOUNDSREAD:
+ DOSET (FLG_LIKELYBOUNDSREAD, b);
+ break;
+ case FLG_BOUNDSWRITE:
+ DOSET (FLG_LIKELYBOUNDSWRITE, b);
break;
+ case FLG_LIKELYBOUNDS:
+ DOSET (FLG_LIKELYBOUNDSREAD, b);
+ DOSET (FLG_LIKELYBOUNDSWRITE, b);
+ break;
+
case FLG_CZECH:
if (b) { DOSET (FLG_ACCESSCZECH, b); }
DOSET (FLG_CZECHFUNCTIONS, b);
context_destroyMod (void)
/*@globals killed gc@*/
{
+ int i;
setCodePoint ();
ctype_destroyMod ();
+ /*
setCodePoint ();
usymtab_free ();
setCodePoint ();
+ */
+
fileTable_free (gc.ftab);
+ gc.ftab = fileTable_undefined;
+
filelocStack_free (gc.locstack);
setCodePoint ();
- gc.ftab = fileTable_undefined;
macrocache_free (gc.mc);
+
+ /* evans 2002-07-12: not reported because of reldef */
+ for (i = 0; i < gc.nmods; i++)
+ {
+ cstring_free (gc.moduleaccess[i].file);
+ }
+
sfree (gc.moduleaccess);
setCodePoint ();
globSet_free (gc.globs_used);
metaStateTable_free (gc.stateTable);
annotationTable_free (gc.annotTable);
+
+
}
/*
-** Flag shortcuts.
+** Flag shortcuts
*/
bool context_msgBoolInt (void)
{
- return gc.flags [FLG_BOOLINT];
+ return context_flagOn (FLG_BOOLINT, g_currentloc);
}
bool context_msgCharInt (void)
{
- return gc.flags [FLG_CHARINT];
+ return context_flagOn (FLG_CHARINT, g_currentloc);
}
bool context_msgEnumInt (void)
{
- return gc.flags [FLG_ENUMINT];
+ return context_flagOn (FLG_ENUMINT, g_currentloc);
+}
+
+bool context_msgLongInt (void)
+{
+ return context_flagOn (FLG_LONGINT, g_currentloc);
+}
+
+bool context_msgShortInt (void)
+{
+ return context_flagOn (FLG_SHORTINT, g_currentloc);
}
bool context_msgPointerArith (void)
{
- return gc.flags [FLG_POINTERARITH];
+ return context_flagOn (FLG_POINTERARITH, g_currentloc);
}
bool context_msgStrictOps (void)
{
- return gc.flags [FLG_STRICTOPS];
+ return context_flagOn (FLG_STRICTOPS, g_currentloc);
}
-# ifndef NOLCL
bool context_msgLh (void)
{
return gc.flags [FLG_DOLH];
}
-# endif
void context_pushLoc (void)
{
return (context_getValue (FLG_EXPECT));
}
-# ifndef NOLCL
int context_getLCLExpect (void)
{
return (context_getValue (FLG_LCLEXPECT));
}
-# endif
int context_getLimit (void)
{
return context_getString (FLG_MERGE);
}
-# ifndef NOLCL
bool context_inLCLLib (void)
{
return (gc.kind == CX_LCLLIB);
}
+
+/*drl add these 3/5/2003*/
+static bool inSizeof = FALSE;
+
+bool context_inSizeof (void)
+{
+ return (inSizeof);
+}
+
+void context_enterSizeof (void)
+{
+ DPRINTF((message("context_enterSizeof ") ) );
+ inSizeof = TRUE;
+}
+
+void context_leaveSizeof (void)
+{
+ DPRINTF((message("context_leaveSizeof ") ));
+ inSizeof = FALSE;
+}
+/*end function added 3/5/2003*/
+
+
bool context_inImport (void)
{
return (gc.inimport);
{
gc.inimport = FALSE;
}
-# endif
bool context_inMacro (void)
{
return (gc.speclinesprocessed);
}
-# ifndef NOLCL
void context_processedSpecLine (void)
{
gc.speclinesprocessed++;
void context_resetSpecLines (void)
{
gc.speclinesprocessed = 0;
+
}
-# endif
bool context_inGlobalContext (void)
{
}
-
/*drl 12/30/01 these are some ugly functions that were added to facilitate struct annotations */
return lastStruct;
}
+/*
+** Why is this stuff in context.c?
+*/
/*@unused@*/ static int sInfoNum = 0;
/*@unused@*/ struct getUe * t ;
};
-
-static struct sInfo globalStructInfo;
-
+/* unused: 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)
+/*@-paramuse@*/
+
+void context_setGlobalStructInfo(ctype ct, constraintList list)
{
- int i;
+# if 0
+ /* int i;
uentryList f;
f = ctype_getFields (ct);
globalStructInfo.ngetUe = 0;
- / *abstraction violation fix it * /
+ /* abstraction violation fix it * /
globalStructInfo.t = dmalloc(f->nelements * sizeof(struct getUe) );
globalStructInfo.ngetUe = f->nelements;
}
end_uentryList_elements;
}
+ */
+# endif
}
-*/
+# if 0
+/*
-bool hasInvariants (ctype ct) /*@*/
+bool hasInvariants (ctype ct) /*@* /
{
if ( ctype_sameName(globalStructInfo.ct, ct) )
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
*/
+# endif
-/*
-constraintList getInvariants (ctype ct)
-{
-
- llassert(hasInvariants(ct) );
-
- return globalStructInfo.inv;
-}
-*/
-
-/*
-static int getSref (ctype ct, sRef s)
-{
- int i;
-
- i = 0;
+/*@=paramuse@*/
- / *
- 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;
-}
-*/