static void printIndentMessage (FILE *p_stream, /*@only@*/ cstring p_sc, int p_indent)
/*@modifies *p_stream@*/ ;
-# ifndef NOLCL
static int lclerrors = 0;
-# endif
-
static size_t lastfileloclen = 10;
static /*@only@*/ cstring lastmsg = cstring_undefined;
static int mcount = 0;
static /*@only@*/ fileloc lastbug = fileloc_undefined;
static bool llgenerrorreal (char *p_srcFile, int p_srcLine,
/*@only@*/ cstring p_s, fileloc p_fl, bool p_iserror, bool p_indent)
- /*@modifies g_msgstream@*/ ;
+ /*@modifies g_warningstream@*/ ;
static bool llgenerroraux (char *p_srcFile, int p_srcLine,
/*@only@*/ cstring p_s, fileloc p_fl, bool p_iserror, bool p_indent)
- /*@modifies g_msgstream@*/ ;
+ /*@modifies g_warningstream@*/ ;
static void printError (FILE *p_stream, /*@only@*/ cstring p_sc)
/*@globals lastfileloclen @*/
static void printMessage (FILE *p_stream, /*@only@*/ cstring p_s)
/*@modifies *p_stream@*/ ;
-static void llgenhint (/*@only@*/ cstring p_s) /*@modifies g_msgstream@*/ ;
+static void llgenhint (/*@only@*/ cstring p_s) /*@modifies g_warningstream@*/ ;
static void showSourceLoc (char *srcFile, int srcLine)
- /*@modifies g_msgstream@*/
+ /*@modifies g_warningstream@*/
{
if (context_getFlag (FLG_SHOWSOURCELOC)) {
llgenhint (message ("%s:%d: Source code error generation point.",
static void
printBugReport (void)
{
- fprintf (stderr, " *** Please report bug to %s ***\n",
+ fprintf (g_errorstream, " *** Please report bug to %s ***\n",
SPLINT_MAINTAINER);
llflush ();
/* don't exit (EXIT_FAILURE); */
static bool s_needsPrepare = TRUE;
-void prepareMessage (void)
+void prepareMessage ()
{
DPRINTF (("Prepare message: %s", bool_unparse (context_loadingLibrary ())));
showHerald ();
if ((context_isPreprocessing () || context_loadingLibrary ())
&& s_needsPrepare
- && context_getDebug (FLG_SHOWSCAN))
+ && context_getFlag (FLG_SHOWSCAN))
{
llflush ();
- fprintf (stderr, " >\n");
+ displayScanClose ();
s_needsPrepare = FALSE;
}
void closeMessage (void)
{
if (context_isPreprocessing ()
- && context_getDebug (FLG_SHOWSCAN))
+ && context_getFlag (FLG_SHOWSCAN))
{
llflush ();
- fprintf (stderr, "< more preprocessing .");
-
+ displayScanOpen (cstring_makeLiteral ("more preprocessing ."));
llassertprotect (!s_needsPrepare);
s_needsPrepare = TRUE;
}
{
context_setNeednl ();
prepareMessage ();
- printMessage (g_msgstream, s);
+ printMessage (g_messagestream, s);
closeMessage ();
}
if (inmsg)
{
- fprintf (stderr, "Recursive message call detected: %s\n", cstring_toCharsSafe (s));
+ fprintf (g_errorstream,
+ "Recursive message call detected: %s\n",
+ cstring_toCharsSafe (s));
llexit (LLFAILURE);
}
context_setNeednl ();
prepareMessage ();
- printMessage (stderr, s);
+ printMessage (g_messagestream, s);
closeMessage ();
inmsg = FALSE;
{
context_setNeednl ();
prepareMessage ();
- printMessage (g_msgstream, s);
+ printMessage (g_messagestream, s);
closeMessage ();
}
{
if (context_getFlag (FLG_WARNFLAGS))
{
- showHerald ();
-
- if (fileloc_isBuiltin (g_currentloc))
- {
- llmsg (message ("Warning: %q", s));
- }
- else
- {
- llgenmsg (message ("Warning: %q", s), g_currentloc);
- }
+ llgenmsg (s, g_currentloc);
}
else
{
}
static void
-llgenhint (/*@only@*/ cstring s) /*@modifies g_msgstream@*/
+llgenhint (/*@only@*/ cstring s) /*@modifies g_warningstream@*/
{
int indent = context_getIndentSpaces () - 1;
if (indent < 0) indent = 0;
context_setNeednl ();
- printIndentMessage (g_msgstream, s, indent);
+ printIndentMessage (g_warningstream, s, indent);
}
void
if (cstring_isDefined (desc))
{
- printError (g_msgstream, message (" %s", desc));
+ printError (g_warningstream, message (" %s", desc));
}
}
}
if (unprinted == 1 && cstring_isDefined (saveOneMessage))
{
prepareMessage ();
- printError (g_msgstream, saveOneMessage);
+ printError (g_warningstream, saveOneMessage);
closeMessage ();
saveOneMessage = cstring_undefined;
}
saveOneMessage = cstring_undefined;
}
- fprintf (g_msgstream, "%s: (%d more similar errors unprinted)\n",
+ fprintf (g_warningstream, "%s: (%d more similar errors unprinted)\n",
cstring_toCharsSafe (fileloc_filename (g_currentloc)),
mcount - context_getLimit ());
}
lastfileloclen = cstring_length (flstring);
prepareMessage ();
- (void) printError (g_msgstream, message ("%q: %q", flstring, s));
+ (void) printError (g_warningstream, message ("%q: %q", flstring, s));
closeMessage ();
}
cstring flstring = fileloc_unparse (fl);
prepareMessage ();
- (void) printIndentMessage (g_msgstream, message ("%q: %q", flstring, s), context_getIndentSpaces ());
+ (void) printIndentMessage (g_warningstream, message ("%q: %q", flstring, s), context_getIndentSpaces ());
closeMessage ();
}
llgenindentmsgnoloc (/*@only@*/ cstring s)
{
prepareMessage ();
- (void) printIndentMessage (g_msgstream, s, context_getIndentSpaces ());
+ (void) printIndentMessage (g_warningstream, s, context_getIndentSpaces ());
closeMessage ();
}
{
if (!bool_equal (ctype_isSigned (ut1), ctype_isSigned (ut2)))
{
- hcode = FLG_IGNORESIGNS;
+ if (ctype_isArbitraryIntegral (ctype_realType (ut1))
+ && !ctype_isArbitraryIntegral (ctype_realType (ut2)))
+ {
+ hcode = FLG_MATCHANYINTEGRAL;
+ }
+ else if (ctype_isArbitraryIntegral (ctype_realType (ut2))
+ && !ctype_isArbitraryIntegral (ctype_realType (ut1)))
+ {
+ hcode = FLG_MATCHANYINTEGRAL;
+ }
+ else
+ {
+ hcode = FLG_IGNORESIGNS;
+ }
}
else
{
if (hcode != INVALID_FLAG && hcode != ocode)
{
code = hcode;
- llshowhint (code);
+ if (context_flagOn (code, fl))
+ {
+ /* The flag is alreay set, something buggy in the flag code */
+ llcontbug (message ("No hint available, flag %s is already set.",
+ flagcode_unparse (code)));
+ }
+ else
+ {
+ llshowhint (code);
+ }
}
else
{
if (context_inIterDef ())
{
- fprintf (g_msgstream, "%s: (in iter %s)\n",
+ fprintf (g_warningstream, "%s: (in iter %s)\n",
cstring_toCharsSafe (fname),
cstring_toCharsSafe (context_inFunctionName ()));
}
else if (context_inIterEnd ())
{
- fprintf (g_msgstream, "%s: (in iter finalizer %s)\n",
+ fprintf (g_warningstream, "%s: (in iter finalizer %s)\n",
cstring_toCharsSafe (fname),
cstring_toCharsSafe (context_inFunctionName ()));
}
else if (context_inMacro ())
{
- fprintf (g_msgstream, "%s: (in macro %s)\n", cstring_toCharsSafe (fname),
+ fprintf (g_warningstream, "%s: (in macro %s)\n", cstring_toCharsSafe (fname),
cstring_toCharsSafe (context_inFunctionName ()));
}
else
{
- fprintf (g_msgstream, "%s: (in function %s)\n",
+ fprintf (g_warningstream, "%s: (in function %s)\n",
cstring_toCharsSafe (fname),
cstring_toCharsSafe (context_inFunctionName ()));
}
if (indent)
{
- printError (g_msgstream, message (" %q: %q", flstring, s));
+ printError (g_warningstream, message (" %q: %q", flstring, s));
}
else
{
- printError (g_msgstream, message ("%q: %q", flstring, s));
+ printError (g_warningstream, message ("%q: %q", flstring, s));
}
showSourceLoc (srcFile, srcLine);
xllfatalbug (char *srcFile, int srcLine, /*@only@*/ cstring s)
{
prepareMessage ();
- printError (stderr, message ("%q: *** Fatal bug: %q",
- fileloc_unparse (g_currentloc), s));
+ printError (g_errorstream, message ("%q: *** Fatal bug: %q",
+ fileloc_unparse (g_currentloc), s));
showSourceLoc (srcFile, srcLine);
printCodePoint ();
printBugReport ();
llexit (LLFAILURE);
}
-# ifndef NOLCL
void
lclfatalbug (char *msg)
{
prepareMessage ();
- printError (stderr,
+ printError (g_errorstream,
message ("*** Fatal Bug: %s", cstring_fromChars (msg)));
printCodePoint ();
printBugReport ();
llexit (LLFAILURE);
}
-# endif
void
checkParseError (void)
{
cstring temps = fileloc_unparseRaw (file, line);
- fprintf (stderr, "%s: Recursive bug detected: %s\n",
+ fprintf (g_errorstream,
+ "%s: Recursive bug detected: %s\n",
cstring_toCharsSafe (temps),
cstring_toCharsSafe (s));
cstring_free (temps);
prepareMessage ();
- /*@i3232@*/
- /*
- if (fileloc_isRealLib (g_currentloc))
- {
- DPRINTF (("Here we are!"));
- llfatalerror (message ("%q: Library file appears to be corrupted. Error: %q: %s",
- fileloc_unparse (g_currentloc),
- fileloc_unparseRaw (file, line),
- s));
- }
- */
-
if (fileloc_withinLines (lastparseerror, g_currentloc, 7))
{
llfatalerror (message ("%q: Cannot recover from parse error.",
fileloc_unparse (g_currentloc)));
}
- (void) fflush (g_msgstream);
-
- printError (stderr, message ("%q: *** Internal Bug at %q: %q [errno: %d]",
- fileloc_unparse (g_currentloc),
- fileloc_unparseRaw (file, line),
- s, errno));
+ (void) fflush (g_warningstream);
+ printError (g_errorstream,
+ message ("%q: *** Internal Bug at %q: %q [errno: %d]",
+ fileloc_unparse (g_currentloc),
+ fileloc_unparseRaw (file, line),
+ s, errno));
+
/* printCodePoint (); no longer useful */
- (void) fflush (stderr);
+ llflush ();
+
+ /*
+ ** This is confusing, and hardly ever useful.
if (errno != 0)
{
perror ("Possible system error diagnostic: ");
}
- (void) fflush (stderr);
+ **
+ */
printBugReport ();
+ llflush ();
numbugs++;
if (numbugs > context_getBugsLimit () && fileloc_withinLines (lastbug, g_currentloc, 2))
{
- llfatalerror (message ("%q: Cannot recover from last bug. (If you really want Splint to try to continue, use -bugslimit <n>.)",
- fileloc_unparse (g_currentloc)));
+ llfatalerror
+ (message ("%q: Cannot recover from last bug. "
+ "(If you really want Splint to try to continue, use -bugslimit <n>.)",
+ fileloc_unparse (g_currentloc)));
}
- fprintf (stderr, " (attempting to continue, results may be incorrect)\n");
+ fprintf (g_errorstream, " (attempting to continue, results may be incorrect)\n");
fileloc_free (lastbug);
lastbug = fileloc_copy (g_currentloc);
closeMessage ();
-
- (void) fflush (stderr);
inbug = FALSE;
}
-# ifndef NOLCL
void
lclbug (/*@only@*/ cstring s)
{
prepareMessage ();
- printError (stderr, message ("*** Internal Bug: %q", s));
+ printError (g_errorstream, message ("*** Internal Bug: %q", s));
printCodePoint ();
printBugReport ();
- fprintf (stderr, " (attempting to continue, results may be incorrect)\n");
+ fprintf (g_errorstream, " (attempting to continue, results may be incorrect)\n");
closeMessage ();
}
-# endif
void
-llfatalerror (cstring s)
+xllfatalerror (char *srcFile, int srcLine, cstring s)
{
prepareMessage ();
- printError (stderr, s);
- printError (stderr, cstring_makeLiteral ("*** Cannot continue."));
+ printError (g_errorstream, s);
+ printError (g_errorstream, cstring_makeLiteral ("*** Cannot continue."));
+ showSourceLoc (srcFile, srcLine);
llexit (LLFAILURE);
}
void
-llfatalerrorLoc (/*@only@*/ cstring s)
+xllfatalerrorLoc (char *srcFile, int srcLine, /*@only@*/ cstring s)
{
prepareMessage ();
- (void) fflush (g_msgstream);
- printError (stderr, message ("%q: %q", fileloc_unparse (g_currentloc), s));
- printError (stderr, cstring_makeLiteral ("*** Cannot continue."));
- (void) fflush (g_msgstream);
+ (void) fflush (g_warningstream);
+ printError (g_errorstream, message ("%q: %q", fileloc_unparse (g_currentloc), s));
+ printError (g_errorstream, cstring_makeLiteral ("*** Cannot continue."));
+ showSourceLoc (srcFile, srcLine);
+ (void) fflush (g_warningstream);
llexit (LLFAILURE);
}
-# ifndef NOLCL
bool
lclHadError (void)
{
if (ltoken_getCode (t) != NOTTOKEN)
{
cstring loc = ltoken_unparseLoc (t);
-
lastfileloclen = cstring_length (loc);
- printError (g_msgstream, message ("%q: %q", loc, msg));
+ printError (g_warningstream, message ("%q: %q", loc, msg));
showSourceLoc (srcFile, srcLine);
}
else
{
- printError (g_msgstream, msg);
+ printError (g_warningstream, msg);
showSourceLoc (srcFile, srcLine);
}
}
lclplainerror (/*@only@*/ cstring msg)
{
lclerrors++;
-
- printError (g_msgstream, msg);
+ printError (g_warningstream, msg);
}
void
lclfatalerror (ltoken t, /*@only@*/ cstring msg)
{
- lclerror (t, msg);
- (void) fflush (g_msgstream);
- printError (stderr, cstring_makeLiteral ("*** Cannot continue"));
+ if (ltoken_getCode (t) != NOTTOKEN)
+ {
+ cstring loc = ltoken_unparseLoc (t);
+ lastfileloclen = cstring_length (loc);
+ printError (g_errorstream, message ("%q: %q", loc, msg));
+ }
+ else
+ {
+ printError (g_errorstream, msg);
+ }
+
+ printError (g_errorstream, cstring_makeLiteral ("*** Cannot continue"));
llexit (LLFAILURE);
}
void
lclplainfatalerror (/*@only@*/ cstring msg)
{
- (void) fflush (g_msgstream);
- printError (stderr, message ("*** Cannot continue: %q", msg));
+ (void) fflush (g_warningstream);
+ printError (g_errorstream, message ("*** Cannot continue: %q", msg));
llexit (LLFAILURE);
}
lclerror (id, message ("Identifier redeclared: %s", s));
}
}
-# endif
void genppllerror (flagcode code, /*@only@*/ cstring s)
{
{
if (context_getFlag (code))
{
- if (context_getFlag (FLG_SHOWSCAN) && !context_isInCommandLine ())
+ if (!context_isInCommandLine ())
{
- fprintf (g_msgstream, " >\n");
+ displayScanClose ();
}
llerror (code, s);
llsuppresshint ('-', code);
}
- if (context_getFlag (FLG_SHOWSCAN) && !context_isInCommandLine ())
+ if (!context_isInCommandLine ())
{
- fprintf (stderr, "< more preprocessing .");
+ displayScanOpen (cstring_makeLiteral ("< more preprocessing ."));
}
}
else
void pplldiagmsg (cstring s)
{
- if (context_getDebug (FLG_SHOWSCAN) && !context_isInCommandLine ())
+ if (!context_isInCommandLine ())
{
- fprintf (stderr, " >\n");
+ displayScanClose ();
lldiagmsg (s);
- fprintf (stderr, "< more preprocessing .");
+ displayScanOpen (cstring_makeLiteral ("< more preprocessing ."));
}
else
{
void loadllmsg (cstring s)
{
- if (context_getDebug (FLG_SHOWSCAN))
- {
- fprintf (stderr, " >\n");
- lldiagmsg (s);
- fprintf (stderr, "< .");
- }
- else
- {
- lldiagmsg (s);
- }
+ displayScanClose ();
+ lldiagmsg (s);
+ displayScanOpen (cstring_makeLiteral ("< ."));
}
static void llreportparseerror (/*@only@*/ cstring s)
return FALSE;
}
-void llparseerror (cstring s)
+void xllparseerror (char *srcFile, int srcLine, cstring s)
{
if (context_getFlag (FLG_TRYTORECOVER))
{
{
if (cstring_isDefined (s))
{
- llfatalerror (message ("%q: Parse Error: %q. "
- "Too many errors, giving up.",
- fileloc_unparse (g_currentloc), s));
+ xllfatalerror (srcFile, srcLine,
+ message ("%q: Parse Error: %q. "
+ "Too many errors, giving up.",
+ fileloc_unparse (g_currentloc), s));
}
else
{
- llfatalerror (message ("%q: Parse Error. Too many errors, giving up.",
- fileloc_unparse (g_currentloc)));
+ xllfatalerror (srcFile, srcLine,
+ message ("%q: Parse Error. Too many errors, giving up.",
+ fileloc_unparse (g_currentloc)));
}
}
else
{
llreportparseerror (message ("Parse Error: %q. Attempting to continue.",
s));
+ showSourceLoc (srcFile, srcLine);
}
else
{
llreportparseerror (message ("Parse Error. Attempting to continue."));
+ showSourceLoc (srcFile, srcLine);
}
}
}
msg = message ("Parse Error.");
}
- llfatalerror
- (message ("%q: %s (For help on parse errors, "
+ xllfatalerror
+ (srcFile, srcLine,
+ message ("%q: %s (For help on parse errors, "
"see splint -help parseerrors.)",
fileloc_unparse (g_currentloc), msg));
}
# if 0
# ifdef HOMEVERSION
llflush ();
- printError (stderr, message ("%q: *** Internal Bug at %q: %q [errno: %d]",
- fileloc_unparse (g_currentloc),
- fileloc_unparseRaw (file, line),
- s, errno));
+ printError (g_errorstream, message ("%q: *** Internal Bug at %q: %q [errno: %d]",
+ fileloc_unparse (g_currentloc),
+ fileloc_unparseRaw (file, line),
+ s, errno));
printCodePoint ();
llflush ();
# endif
void llflush (void)
{
- (void) fflush (g_msgstream);
- (void) fflush (stderr);
+ (void) fflush (g_warningstream);
+ (void) fflush (g_messagestream);
}
+
+static bool s_scanOpen = FALSE;
+
+void displayScan (cstring msg)
+{
+ if (s_scanOpen)
+ {
+ displayScanClose ();
+ }
+
+ llassert (!s_scanOpen);
+
+ if (context_getFlag (FLG_SHOWSCAN))
+ {
+ showHerald ();
+ fprintf (g_messagestream, "< %s >\n", cstring_toCharsSafe (msg));
+ (void) fflush (g_messagestream);
+ }
+
+ cstring_free (msg);
+}
+
+void displayScanOpen (cstring msg)
+{
+ if (s_scanOpen)
+ {
+ displayScanClose ();
+ }
+
+ llassert (!s_scanOpen);
+ s_scanOpen = TRUE;
+
+ if (context_getFlag (FLG_SHOWSCAN))
+ {
+ fprintf (g_messagestream, "< %s", cstring_toCharsSafe (msg));
+ (void) fflush (g_messagestream);
+ }
+
+ cstring_free (msg);
+}
+
+void displayScanContinue (/*@temp@*/ cstring msg)
+{
+ if (context_getFlag (FLG_SHOWSCAN))
+ {
+ if (s_scanOpen)
+ {
+ fprintf (g_messagestream, "%s", cstring_toCharsSafe (msg));
+ (void) fflush (g_messagestream);
+ }
+ else
+ {
+ /*
+ ** Don't call bug recursively
+ */
+
+ fprintf (stderr, "*** Bug: scan continue scan not open\n");
+ }
+ }
+}
+
+void displayScanClose (void)
+{
+ if (s_scanOpen)
+ {
+ if (context_getFlag (FLG_SHOWSCAN))
+ {
+ fprintf (g_messagestream, " >\n");
+ (void) fflush (g_messagestream);
+ }
+ }
+ else
+ {
+ /*
+ ** Don't call bug recursively
+ */
+
+ fprintf (stderr, "*** Bug: scan close scan not open\n");
+ }
+
+ s_scanOpen = FALSE;
+}
+
+