aliasTable_levelUnionNew (aliasTable p_t1, aliasTable p_t2, int p_level)
/*@modifies nothing*/ ;
-extern void aliasTable_checkGlobs (aliasTable p_t) /*@modifies g_msgstream@*/ ;
+extern void aliasTable_checkGlobs (aliasTable p_t) /*@modifies g_warningstream@*/ ;
extern /*@only@*/ sRefSet aliasTable_aliasedBy (aliasTable p_s, sRef p_sr) /*@*/ ;
extern void aliasTable_fixSrefs (aliasTable p_s);
extern aliasTable aliasTable_levelUnionSeq (/*@returned@*/ aliasTable p_t1,
extern void context_setString (flagcode p_flag, /*@only@*/ cstring p_val)
/*@modifies internalState@*/ ;
-extern bool context_getDebug (flagcode p_d);
-# define context_getDebug(p_d) context_getFlag(p_d)
-
extern void context_userSetFlag (flagcode p_f, bool p_b);
extern int context_getExpect (void) /*@*/ ;
extern /*@observer@*/ cstring context_moduleName (void) /*@*/ ;
extern void context_recordFileGlobals (/*@dependent@*/ globSet p_mods);
-extern void context_checkSuppressCounts (void) /*@modifies g_msgstream@*/ ;
+extern void context_checkSuppressCounts (void) /*@modifies g_warningstream@*/ ;
extern bool context_inFunctionHeader (void) /*@globals internalState@*/ ;
extern void context_enterFunctionHeader (void) /*@modifies internalState@*/ ;
extern void cppReader_error (cppReader *p_pfile, /*@only@*/ cstring p_msg);
extern void cppReader_warning (cppReader *p_pfile, /*@only@*/ cstring p_msg);
-extern void cppReader_printContainingFiles (cppReader *p_pfile) /*@modifies g_msgstream, p_pfile@*/ ;
+extern void cppReader_printContainingFiles (cppReader *p_pfile) /*@modifies g_warningstream, p_pfile@*/ ;
extern void cppReader_warningLit (cppReader *p_pfile, /*@observer@*/ cstring p_msg);
extern void cppReader_pedwarn (cppReader *p_pfile, /*@only@*/ cstring p_msg);
extern void cppReader_pedwarnLit (cppReader *p_pfile, /*@observer@*/ cstring p_msg);
extern void cppReader_errorWithLine (cppReader *p_pfile,
- long p_line, long p_column,
+ int p_line, int p_column,
/*@only@*/ cstring p_msg);
extern void cppReader_perrorWithName (cppReader *p_pfile, cstring p_name);
};
typedef struct if_stack cppIfStackFrame;
-extern void cppBuffer_lineAndColumn (/*@null@*/ cppBuffer *, /*@out@*/ int *,
- /*@out@*/ /*@null@*/ int *);
+extern void cppBuffer_getLineAndColumn (/*@null@*/ cppBuffer *, /*@out@*/ int *,
+ /*@out@*/ /*@null@*/ int *);
extern /*@exposed@*/ /*@null@*/ cppBuffer *cppReader_fileBuffer (cppReader *);
extern void cppReader_growBuffer (cppReader *, size_t);
{
cstring literal;
cstring id;
- lltok *tok;
+ lltok tok;
qtype qt; /* sizeof(type) */
/* use for any 2-operator (comma, arrayFetch, case, stmt) */
exprPair pair;
extern exprNode exprNode_makeBlock (/*@only@*/ exprNode p_e);
extern exprNode exprNode_compoundStatementExpression (/*@only@*/ lltok p_tlparen, /*@only@*/ exprNode p_e) ;
-extern void exprNode_checkIfPred (exprNode p_pred) /*@modifies g_msgstream@*/ ;
+extern void exprNode_checkIfPred (exprNode p_pred) /*@modifies g_warningstream@*/ ;
extern exprNode exprNode_if (/*@only@*/ exprNode p_pred, /*@only@*/ exprNode p_tclause);
extern exprNode
extern /*@observer@*/ cstring fileTable_getNameBase (fileTable p_ft, fileId p_fid) ;
extern fileId fileTable_addFile (fileTable p_ft, cstring p_name)
/*@modifies p_ft@*/ ;
+
+extern void fileTable_addStreamFile (fileTable p_ft, /*@dependent@*/ FILE *p_fstream,
+ cstring p_name)
+ /*@modifies p_ft@*/ ;
+
extern fileId fileTable_addHeaderFile (fileTable p_ft, cstring p_name)
/*@modifies p_ft@*/ ;
extern fileId fileTable_addXHFile (fileTable p_ft, cstring p_name)
extern bool fileTable_sameBase (fileTable p_ft, fileId p_f1, fileId p_f2);
extern void fileTable_cleanup (fileTable p_ft) /*@modifies fileSystem@*/;
extern fileId fileTable_lookupBase (fileTable p_ft, cstring p_base) /*@modifies p_ft@*/ ;
-extern void fileTable_printTemps (fileTable p_ft) /*@modifies g_msgstream@*/ ;
+extern void fileTable_printTemps (fileTable p_ft) /*@modifies g_warningstream@*/ ;
extern /*@unused@*/ /*@only@*/ cstring fileTable_unparse (fileTable p_ft) /*@*/ ;
extern bool fileTable_exists (fileTable p_ft, cstring p_s) /*@*/ ;
extern void fileTable_free (/*@only@*/ fileTable p_f);
# define filelocStack_size(s) (filelocStack_isDefined (s) ? (s)->nelements : 0)
extern int filelocStack_includeDepth (filelocStack p_s);
-extern void filelocStack_printIncludes (filelocStack p_s) /*@modifies g_msgstream@*/ ;
+extern void filelocStack_printIncludes (filelocStack p_s) /*@modifies g_warningstream@*/ ;
extern void filelocStack_clear (filelocStack p_s) /*@modifies p_s@*/ ;
flagMarkerList_suppressError (flagMarkerList p_s, flagcode p_code, fileloc p_loc) /*@*/ ;
extern void flagMarkerList_checkSuppressCounts (flagMarkerList p_s)
- /*@modifies g_msgstream@*/ ;
+ /*@modifies g_warningstream@*/ ;
extern bool
flagMarkerList_inIgnore (flagMarkerList p_s, fileloc p_loc) /*@*/ ;
# define NUMVALUEFLAGS 14
/*@constant int NUMSTRINGFLAGS; @*/
-# define NUMSTRINGFLAGS 24
+# define NUMSTRINGFLAGS 27
/*@iter allFlagCodes (yield flagcode f); @*/
# define allFlagCodes(m_code) \
extern /*@only@*/ cstring describeFlag (cstring p_flagname);
-extern flagcode flags_identifyFlag (cstring p_s) /*@modifies g_msgstream@*/ ;
+extern flagcode flags_identifyFlag (cstring p_s) /*@modifies g_warningstream@*/ ;
extern flagcode flags_identifyFlagQuiet (cstring p_s) /*@modifies nothing@*/ ;
extern void setValueFlag (flagcode p_opt, cstring p_arg);
extern /*@observer@*/ cstring flagcodeHint (flagcode p_f);
extern flagkind identifyCategory (cstring p_s) /*@*/ ;
-extern void printCategory (flagkind p_kind) /*@modifies g_msgstream@*/ ;
+extern void printCategory (flagkind p_kind) /*@modifies g_warningstream@*/ ;
extern bool flagcode_isInvalid (flagcode p_f) /*@*/ ;
# define flagcode_isInvalid(f) ((f) == INVALID_FLAG)
# define flagcode_isWarnUseFlag(f) \
((f) == FLG_BUFFEROVERFLOW || (f) == FLG_BUFFEROVERFLOWHIGH)
-extern bool flagcode_hasNumber (flagcode p_f);
-extern bool flagcode_hasChar (flagcode p_f);
-extern bool flagcode_hasString (flagcode p_f);
-extern bool flagcode_hasArgument (flagcode p_f);
+extern bool flagcode_hasNumber (flagcode p_f) /*@*/ ;
+extern bool flagcode_hasChar (flagcode p_f) /*@*/ ;
+extern bool flagcode_hasString (flagcode p_f) /*@*/ ;
+extern bool flagcode_hasArgument (flagcode p_f) /*@*/ ;
/*@constant observer cstring DEFAULT_MODE;@*/
# define DEFAULT_MODE (cstring_makeLiteralTemp ("standard"))
-extern void flags_initMod (void);
+extern void flags_initMod (void) /*@modifies internalState@*/ ;
-extern bool isMode (cstring p_s);
-extern /*@only@*/ cstring describeModes (void);
-extern void summarizeErrors (void);
-
-extern bool flagcode_isNameChecksFlag (flagcode p_f);
-extern bool flagcode_isIdemFlag (flagcode p_f);
-extern bool flagcode_isModeFlag (flagcode p_f);
-extern bool flagcode_isSpecialFlag (flagcode p_f);
-extern bool flagcode_isGlobalFlag (flagcode p_f);
+extern bool isMode (cstring p_s) /*@*/ ;
+extern /*@only@*/ cstring describeModes (void) /*@modifies g_messagestream@*/ ;
+extern void summarizeErrors (void) /*@modifies g_messagestream@*/ ;
+extern bool flagcode_isNameChecksFlag (flagcode p_f) /*@*/ ;
+extern bool flagcode_isIdemFlag (flagcode p_f) /*@*/ ;
+extern bool flagcode_isModeFlag (flagcode p_f) /*@*/ ;
+extern bool flagcode_isSpecialFlag (flagcode p_f) /*@*/ ;
+extern bool flagcode_isGlobalFlag (flagcode p_f) /*@*/ ;
+extern bool flagcode_isMessageControlFlag (flagcode p_f) /*@*/ ;
+
# else
# error "Multiple include"
# endif
extern /*@owned@*/ fileloc g_currentloc;
+/*
+** All the streams are unchecked for now.
+*/
+
+/* stream for warning messages */
+/*@unchecked@*/ extern /*@relnull@*/ /*@dependent@*/ /*:open:*/ FILE *g_warningstream;
+
+/* stream for status messages */
+/*@unchecked@*/ extern /*@relnull@*/ /*@dependent@*/ /*:open:*/ FILE *g_messagestream;
+
/* stream for error messages */
-extern /*:open:*/ FILE *g_msgstream;
+/*@unchecked@*/ extern /*@relnull@*/ /*@dependent@*/ /*:open:*/ FILE *g_errorstream;
/*@-ansireserved@*/
/* This macro is defined by flex. */
** llassertprint and llassertprintret are in splintMacros.nf
*/
-extern void llmsg (/*@only@*/ cstring p_s) /*@modifies g_msgstream@*/ ;
+extern void llmsg (/*@only@*/ cstring p_s) /*@modifies g_warningstream@*/ ;
extern void lldiagmsg (/*@only@*/ cstring p_s) /*@modifies stderr@*/ ;
-extern void llmsgplain (/*@only@*/ cstring p_s) /*@modifies g_msgstream@*/ ;
+extern void llmsgplain (/*@only@*/ cstring p_s) /*@modifies g_warningstream@*/ ;
extern void llhint (/*@only@*/ cstring p_s)
- /*@globals g_currentloc, g_msgstream;@*/
- /*@modifies g_msgstream@*/ ;
+ /*@globals g_currentloc, g_warningstream;@*/
+ /*@modifies g_warningstream@*/ ;
-extern /*@private@*/ /*@noreturn@*/ void xllfatalbug (char *p_srcFile, int p_srcLine,
- /*@only@*/ cstring p_s)
+extern /*@private@*/ /*@noreturn@*/ void
+xllfatalbug (char *p_srcFile, int p_srcLine, /*@only@*/ cstring p_s)
/*@globals g_currentloc@*/
- /*@modifies stderr@*/ ;
+ /*@modifies g_errorstream@*/ ;
extern /*@noreturn@*/ void llfatalbug (/*@only@*/ cstring p_s)
/*@globals g_currentloc@*/
- /*@modifies stderr@*/ ;
+ /*@modifies g_errorstream@*/ ;
+
# define llfatalbug(p_s) \
xllfatalbug (__FILE__, __LINE__, p_s)
extern /*@private@*/ bool xllgenerror (char *p_srcFile, int p_srcLine, flagcode p_o,
/*@only@*/ cstring p_s, fileloc p_fl)
- /*@modifies g_msgstream@*/ ;
+ /*@modifies g_warningstream@*/ ;
extern bool llgenerror (flagcode p_o, /*@only@*/ cstring p_s, fileloc p_fl)
- /*@modifies g_msgstream@*/ ;
+ /*@modifies g_warningstream@*/ ;
# define llgenerror(p_o, p_s, p_fl) \
xllgenerror (__FILE__, __LINE__, p_o, p_s, p_fl)
xllgenhinterror (char *p_srcFile, int p_srcLine,
flagcode p_o, /*@only@*/ cstring p_s, /*@only@*/ cstring p_hint,
fileloc p_fl)
- /*@modifies g_msgstream@*/ ;
+ /*@modifies g_warningstream@*/ ;
extern bool llgenhinterror (flagcode p_o, /*@only@*/ cstring p_s, /*@only@*/ cstring p_hint,
- fileloc p_fl) /*@modifies g_msgstream@*/ ;
+ fileloc p_fl) /*@modifies g_warningstream@*/ ;
# define llgenhinterror(p_o, p_s, p_hint, p_fl) \
xllgenhinterror (__FILE__, __LINE__, p_o, p_s, p_hint, p_fl)
extern void llerror (flagcode p_o, /*@only@*/ cstring p_s)
- /*@globals g_msgstream, g_currentloc@*/
- /*@modifies g_msgstream@*/ ;
+ /*@globals g_warningstream, g_currentloc@*/
+ /*@modifies g_warningstream@*/ ;
# define llerror(p_o, p_s) \
((void) llgenerror (p_o, p_s, g_currentloc))
-extern void llgenmsg (/*@only@*/ cstring p_s, fileloc p_fl) /*@modifies g_msgstream@*/ ;
-extern /*@noreturn@*/ void llfatalerror (/*@only@*/ cstring p_s) /*@modifies g_msgstream@*/ ;
+extern void llgenmsg (/*@only@*/ cstring p_s, fileloc p_fl)
+ /*@modifies g_warningstream@*/ ;
+
+extern /*@noreturn@*/ void llfatalerror (/*@only@*/ cstring p_s)
+ /*@modifies g_errorstream@*/ ;
+
extern /*@noreturn@*/ void llfatalerrorLoc (/*@only@*/ cstring p_s)
/*@globals g_currentloc@*/
- /*@modifies stderr@*/ ;
+ /*@modifies g_errorstream@*/ ;
+
extern void llparseerror (/*@only@*/ cstring p_s)
- /*@globals g_msgstream, g_currentloc@*/
- /*@modifies g_msgstream@*/ ;
+ /*@globals g_errorstream, g_currentloc@*/
+ /*@modifies g_errorstream@*/ ;
# ifndef NOLCL
-extern /*@noreturn@*/ void lclplainfatalerror (/*@only@*/ cstring p_msg) /*@modifies g_msgstream@*/ ;
-extern /*@noreturn@*/ void lclfatalbug (/*@temp@*/ char *p_msg) /*@modifies g_msgstream@*/ ;
+extern /*@noreturn@*/ void lclplainfatalerror (/*@only@*/ cstring p_msg) /*@modifies g_warningstream@*/ ;
+extern /*@noreturn@*/ void lclfatalbug (/*@temp@*/ char *p_msg) /*@modifies g_warningstream@*/ ;
extern int lclNumberErrors (void) /*@*/ ;
extern bool lclHadNewError (void) /*@modifies internalState@*/ ;
extern /*@noreturn@*/ void lclfatalerror (ltoken p_t, /*@only@*/ cstring p_msg);
extern void lclRedeclarationError (ltoken p_id);
# endif
-extern void llerror_flagWarning (/*@only@*/ cstring p_s) /*@modifies g_msgstream@*/ ;
+extern void llerror_flagWarning (/*@only@*/ cstring p_s) /*@modifies g_warningstream@*/ ;
extern /*@noreturn@*/ void llbugaux (cstring p_file, int p_line, /*@only@*/ cstring p_s)
- /*@globals g_msgstream, g_currentloc@*/
- /*@modifies *g_msgstream@*/ ;
+ /*@globals g_warningstream, g_currentloc@*/
+ /*@modifies *g_warningstream@*/ ;
extern /*@noreturn@*/ void llbug (/*@only@*/ cstring p_s)
- /*@globals g_msgstream, g_currentloc@*/
- /*@modifies *g_msgstream@*/ ;
+ /*@globals g_warningstream, g_currentloc@*/
+ /*@modifies *g_warningstream@*/ ;
/* doesn't really exit, but don't mind errors if it doesn't */
# define llbug(s) llbugaux (cstring_makeLiteralTemp (__FILE__), __LINE__, s)
-extern void llquietbugaux (/*@only@*/ cstring p_s, cstring, int) /*@modifies *g_msgstream@*/ ;
-extern void llquietbug (/*@only@*/ cstring) /*@modifies *g_msgstream@*/ ;
+extern void llquietbugaux (/*@only@*/ cstring p_s, cstring, int) /*@modifies *g_warningstream@*/ ;
+extern void llquietbug (/*@only@*/ cstring) /*@modifies *g_warningstream@*/ ;
# define llquietbug(s) llquietbugaux (s, cstring_makeLiteralTemp (__FILE__), __LINE__)
-extern void llcontbug (/*@only@*/ cstring p_s) /*@modifies *g_msgstream@*/ ;
+extern void llcontbug (/*@only@*/ cstring p_s) /*@modifies *g_warningstream@*/ ;
/* doesn't really exit, but don't mind errors if it doesn't */
# define llcontbug(s) (llbug (s))
extern void cleanupMessages (void)
- /*@globals g_msgstream, g_currentloc;@*/
- /*@modifies g_msgstream, internalState@*/ ;
+ /*@globals g_warningstream, g_currentloc;@*/
+ /*@modifies g_warningstream, internalState@*/ ;
+
+extern void displayScan (/*@only@*/ cstring p_msg)
+ /*@modifies g_messagestream@*/ ;
+
+extern void displayScanOpen (/*@only@*/ cstring p_msg)
+ /*@modifies g_messagestream@*/ ;
+
+extern void displayScanContinue (/*@temp@*/ cstring p_msg)
+ /*@modifies g_messagestream@*/ ;
+
+extern void displayScanClose (void)
+ /*@modifies g_messagestream@*/ ;
/*
** Report error iff f1 and f2 are set.
extern bool
xoptgenerror2 (char *p_srcFile, int p_srcLine,
flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
- /*@modifies *g_msgstream, internalState@*/ ;
+ /*@modifies *g_warningstream, internalState@*/ ;
extern bool
optgenerror2 (flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
- /*@modifies *g_msgstream, internalState@*/ ;
+ /*@modifies *g_warningstream, internalState@*/ ;
# define optgenerror2(p_f1, p_f2, p_s, p_loc) \
(xoptgenerror2 (__FILE__, __LINE__, p_f1, p_f2, p_s, p_loc))
extern bool
xoptgenerror2n (char *p_srcFile, int p_srcLine,
flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
- /*@modifies *g_msgstream, internalState@*/ ;
+ /*@modifies *g_warningstream, internalState@*/ ;
extern bool
optgenerror2n (flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
- /*@modifies *g_msgstream, internalState@*/ ;
+ /*@modifies *g_warningstream, internalState@*/ ;
# define optgenerror2n(p_f1, p_f2, p_s, p_loc) \
(xoptgenerror2n (__FILE__, __LINE__, p_f1, p_f2, p_s, p_loc))
extern /*@private@*/ bool xlloptgenerror (char *p_srcFile, int p_srcLine, flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
- /*@modifies *g_msgstream, internalState@*/ ;
+ /*@modifies *g_warningstream, internalState@*/ ;
extern bool lloptgenerror (flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
- /*@modifies *g_msgstream, internalState@*/ ;
+ /*@modifies *g_warningstream, internalState@*/ ;
# define lloptgenerror(p_o, p_s, p_loc) \
(xlloptgenerror (__FILE__, __LINE__, p_o, p_s, p_loc))
extern bool xllnoptgenerror (char *p_srcFile, int p_srcLine,
flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
- /*@modifies *g_msgstream, internalState@*/ ;
+ /*@modifies *g_warningstream, internalState@*/ ;
extern bool llnoptgenerror (flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
- /*@modifies *g_msgstream, internalState@*/ ;
+ /*@modifies *g_warningstream, internalState@*/ ;
# define llnoptgenerror(p_o, p_s, p_loc) \
(xllnoptgenerror (__FILE__, __LINE__, p_o, p_s, p_loc))
ctype p_t1, exprNode p_e1,
ctype p_t2, exprNode p_e2,
/*@only@*/ cstring p_s, fileloc p_fl)
- /*@modifies *g_msgstream, internalState@*/ ;
+ /*@modifies *g_warningstream, internalState@*/ ;
extern bool llgenformattypeerror (ctype p_t1, exprNode p_e1,
ctype p_t2, exprNode p_e2,
/*@only@*/ cstring p_s, fileloc p_fl)
- /*@modifies *g_msgstream, internalState@*/ ;
+ /*@modifies *g_warningstream, internalState@*/ ;
# define llgenformattypeerror(p_t1, p_e1, p_t2, p_e2, p_s, p_fl) \
xllgenformattypeerror (__FILE__, __LINE__, p_t1, p_e1, p_t2, p_e2, p_s, p_fl)
ctype p_t2, exprNode p_e2,
/*@only@*/ cstring p_s,
fileloc p_fl)
- /*@modifies *g_msgstream, internalState@*/ ;
+ /*@modifies *g_warningstream, internalState@*/ ;
extern bool llgentypeerror (ctype p_t1, exprNode p_e1,
ctype p_t2, exprNode p_e2,
/*@only@*/ cstring p_s,
fileloc p_fl)
- /*@modifies *g_msgstream, internalState@*/ ;
+ /*@modifies *g_warningstream, internalState@*/ ;
# define llgentypeerror(p_t1, p_e1, p_t2, p_e2, p_s, p_fl) \
xllgentypeerror (__FILE__, __LINE__, p_t1, p_e1, p_t2, p_e2, p_s, p_fl)
/*@sef@*/ exprNode p_e2,
/*@sef@*/ /*@only@*/ cstring p_s,
/*@sef@*/ fileloc p_loc)
- /*@modifies *g_msgstream, internalState@*/ ;
+ /*@modifies *g_warningstream, internalState@*/ ;
/*@-branchstate@*/ /* sef only s is freed on one branch */
#define gentypeerror(t1, e1, t2, e2, s, loc) \
extern bool
optgenerror (/*@sef@*/ flagcode p_o, /*@sef@*/ /*@only@*/ cstring p_s,
/*@sef@*/ fileloc p_loc)
- /*@modifies *g_msgstream, internalState@*/ ;
+ /*@modifies *g_warningstream, internalState@*/ ;
/*@-branchstate@*/ /* sef only s is freed on one branch */
#define optgenerror(o,s,loc) \
extern void
voptgenerror (/*@sef@*/ flagcode p_o, /*@sef@*/ /*@only@*/ cstring p_s,
/*@sef@*/ fileloc p_loc)
- /*@modifies *g_msgstream, internalState@*/ ;
+ /*@modifies *g_warningstream, internalState@*/ ;
#define voptgenerror(o, s, loc) ((void) optgenerror(o,s,loc))
extern /*@private@*/ bool
xfsgenerror (char *p_srcFile, int p_srcLine,
flagSpec p_fs, /*@only@*/ cstring p_s, fileloc p_fl)
- /*@modifies g_msgstream, internalState@*/ ;
+ /*@modifies g_warningstream, internalState@*/ ;
extern bool fsgenerror (flagSpec p_fs, /*@only@*/ cstring p_s, fileloc p_fl)
- /*@modifies g_msgstream, internalState@*/ ;
+ /*@modifies g_warningstream, internalState@*/ ;
# define fsgenerror(p_fs, p_s, p_fl) \
xfsgenerror (__FILE__, __LINE__, p_fs, p_s, p_fl)
extern void
vfsgenerror (/*@sef@*/ flagSpec p_fs, /*@sef@*/ /*@only@*/ cstring p_s,
/*@sef@*/ fileloc p_loc)
- /*@modifies *g_msgstream, internalState@*/ ;
+ /*@modifies *g_warningstream, internalState@*/ ;
#define vfsgenerror(fs, s, loc) ((void) fsgenerror(fs,s,loc))
/*
extern /*@private@*/ bool /*@alt void@*/ xllforceerror (char *p_srcFile, int p_srcLine, flagcode p_code, /*@only@*/ cstring p_s, fileloc p_fl)
- /*@modifies g_msgstream@*/ ;
+ /*@modifies g_warningstream@*/ ;
extern bool /*@alt void@*/ llforceerror (flagcode p_code, /*@only@*/ cstring p_s, fileloc p_fl)
- /*@modifies g_msgstream@*/ ;
+ /*@modifies g_warningstream@*/ ;
# define llforceerror(p_code, p_s, p_fl) \
(xllforceerror (__FILE__, __LINE__, p_code, p_s, p_fl))
extern /*@private@*/ bool xcppoptgenerror (char *p_srcFile, int p_srcLine, flagcode p_o,
/*@only@*/ cstring p_s, cppReader *p_pfile)
- /*@modifies g_msgstream, p_pfile@*/ ;
+ /*@modifies g_warningstream, p_pfile@*/ ;
-extern bool cppoptgenerror (flagcode p_code, /*@only@*/ cstring p_s, cppReader *p_pfile)
- /*@modifies g_msgstream, p_pfile@*/ ;
+extern bool /*@alt void@*/
+cppoptgenerror (flagcode p_code, /*@only@*/ cstring p_s, cppReader *p_pfile)
+ /*@modifies g_warningstream, p_pfile@*/ ;
# define cppoptgenerror(p_code, p_s, p_pfile) \
(xcppoptgenerror (__FILE__, __LINE__, p_code, p_s, p_pfile))
extern void llerrorlit (flagcode p_o, char *p_s);
# define llerrorlit(o, s) ((void) llerror (o, cstring_makeLiteral (s)))
-extern void llgenindentmsg (/*@only@*/ cstring p_s, fileloc p_fl) /*@modifies g_msgstream@*/ ;
+extern void llgenindentmsg (/*@only@*/ cstring p_s, fileloc p_fl) /*@modifies g_warningstream@*/ ;
extern /*@noreturn@*/ void llbugexitlit (char *p_s);
# define llbugexitlit(s) (llbug (cstring_makeLiteral (s)))
# define llmsglit(s) (llmsg (cstring_makeLiteral (s)))
extern void ppllerror (/*@only@*/ cstring p_s);
+
extern void genppllerrorhint (flagcode p_code, /*@only@*/ cstring p_s,
/*@only@*/ cstring p_hint);
extern void genppllerror (flagcode p_code, /*@only@*/ cstring p_s);
extern /*@observer@*/ cstring lldecodeerror (int) /*@*/ ;
-extern void prepareMessage (void) /*@modifies internalState, g_msgstream@*/ ;
-extern void closeMessage (void) /*@modifies internalState, g_msgstream@*/ ;
+/*@i523@*/
+/*
+** should be static, but used in cpperror (which shouldn't exist)
+*/
+
+extern void prepareMessage (void)
+ /*@modifies internalState, g_messagestream@*/ ;
+
+extern void closeMessage (void)
+ /*@modifies internalState, g_messagestream@*/ ;
extern void llflush (void) /*@modifies systemState@*/ ;
# include "llgrammar_gen.h"
/*@-redecl@*/ /*@-declundef@*/
-extern void ylerror (char *p_s) /*@modifies *g_msgstream@*/ ;
+extern void ylerror (char *p_s) /*@modifies *g_warningstream@*/ ;
/*@=redecl@*/ /*@=declundef@*/
# else
# ifdef NOLCL
/*@globals killed undef g_currentloc,
killed undef yyin,
- undef g_msgstream,
+ undef g_warningstream,
@*/
/*@modifies g_currentloc, fileSystem, internalState, yyin;
@*/
killed undef g_currentSpecName,
killed undef g_currentloc,
killed undef yyin,
- undef g_msgstream;
+ undef g_warningstream;
@*/
/*@modifies g_currentloc,
g_localSpecPath, g_currentSpec, g_currentSpecName,
# ifndef LLTOK_H
# define LLTOK_H
-typedef struct
+typedef /*@abstract@*/ struct
{
int tok;
fileloc loc;
-} lltok;
+} *lltok;
extern lltok lltok_create (int p_tok, /*@only@*/ fileloc p_loc) /*@modifies nothing@*/ ;
extern /*@observer@*/ cstring lltok_unparse (lltok p_tok) /*@*/ ;
-
-extern void lltok_release (/*@special@*/ lltok p_t) /*@releases p_t.loc@*/ ;
+extern void lltok_free (/*@only@*/ lltok p_t) ;
extern /*@dependent@*/ /*@exposed@*/ fileloc lltok_getLoc (lltok p_t) /*@*/ ;
-extern /*@only@*/ fileloc lltok_stealLoc (lltok p_t) /*@releases p_t.loc@*/ ;
-
extern int lltok_getTok (lltok p_t) /*@*/ ;
-# define lltok_getTok(t) ((t).tok)
-# define lltok_getLoc(t) ((t).loc)
+# define lltok_getTok(t) ((t)->tok)
+# define lltok_getLoc(t) ((t)->loc)
extern bool lltok_isSemi (lltok p_tok);
# ifndef NAMECHECKS_H
# define NAMECHECKS_H
-extern void checkCppName (uentry p_ue) /*@modifies g_msgstream, p_ue@*/ ;
-extern void checkExternalName (uentry p_ue) /*@modifies g_msgstream, p_ue@*/ ;
-extern void checkLocalName (uentry p_ue) /*@modifies g_msgstream, p_ue@*/ ;
-extern void checkFileScopeName (uentry p_ue) /*@modifies g_msgstream, p_ue@*/ ;
-extern void checkPrefix (uentry p_ue) /*@modifies g_msgstream, p_ue@*/ ;
-extern void checkAnsiName (uentry p_ue) /*@modifies g_msgstream, p_ue@*/ ;
-extern void checkParamNames (uentry p_ue) /*@modifies g_msgstream@*/;
+extern void checkCppName (uentry p_ue) /*@modifies g_warningstream, p_ue@*/ ;
+extern void checkExternalName (uentry p_ue) /*@modifies g_warningstream, p_ue@*/ ;
+extern void checkLocalName (uentry p_ue) /*@modifies g_warningstream, p_ue@*/ ;
+extern void checkFileScopeName (uentry p_ue) /*@modifies g_warningstream, p_ue@*/ ;
+extern void checkPrefix (uentry p_ue) /*@modifies g_warningstream, p_ue@*/ ;
+extern void checkAnsiName (uentry p_ue) /*@modifies g_warningstream, p_ue@*/ ;
+extern void checkParamNames (uentry p_ue) /*@modifies g_warningstream@*/;
/*@i32! should get error without modifies p_ue@*/
# else
sRef_fixBase (/*@returned@*/ sRef p_s, /*@returned@*/ sRef p_base)
/*@modifies p_s, p_base@*/ ;
-extern void sRef_showNotReallyDefined (sRef p_s) /*@modifies g_msgstream@*/ ;
+extern void sRef_showNotReallyDefined (sRef p_s) /*@modifies g_warningstream@*/ ;
extern void sRef_enterFunctionScope (void) /*@modifies internalState@*/ ;
extern void sRef_setGlobalScope (void) /*@modifies internalState@*/ ;
extern ynm sRef_isValidLvalue (sRef p_s) /*@*/ ;
extern bool sRef_isStrictReadable (sRef p_s) /*@*/ ;
extern bool sRef_hasNoStorage (sRef p_s) /*@*/ ;
-extern void sRef_showExpInfo (sRef p_s) /*@modifies g_msgstream*/ ;
+extern void sRef_showExpInfo (sRef p_s) /*@modifies g_warningstream*/ ;
extern void sRef_setDefined (sRef p_s, fileloc p_loc) /*@modifies p_s@*/ ;
extern void sRef_setUndefined (sRef p_s, fileloc p_loc) /*@modifies p_s@*/ ;
extern void sRef_setOnly (sRef p_s, fileloc p_loc) /*@modifies p_s@*/ ;
extern void sRef_setKeptComplete (sRef p_s, fileloc p_loc) /*@modifies p_s@*/ ;
extern void sRef_setFresh (sRef p_s, fileloc p_loc) /*@modifies p_s@*/ ;
extern void sRef_setShared (sRef p_s, fileloc p_loc) /*@modifies p_s@*/ ;
-extern void sRef_showAliasInfo (sRef p_s) /*@modifies g_msgstream@*/ ;
-extern void sRef_showMetaStateInfo (sRef p_s, cstring p_key) /*@modifies g_msgstream@*/ ;
-extern void sRef_showNullInfo (sRef p_s) /*@modifies g_msgstream@*/ ;
-extern void sRef_showStateInfo (sRef p_s) /*@modifies g_msgstream@*/ ;
+extern void sRef_showAliasInfo (sRef p_s) /*@modifies g_warningstream@*/ ;
+extern void sRef_showMetaStateInfo (sRef p_s, cstring p_key) /*@modifies g_warningstream@*/ ;
+extern void sRef_showNullInfo (sRef p_s) /*@modifies g_warningstream@*/ ;
+extern void sRef_showStateInfo (sRef p_s) /*@modifies g_warningstream@*/ ;
extern void sRef_setStateFromType (sRef p_s, ctype p_ct) /*@modifies p_s@*/ ;
extern void sRef_kill (sRef p_s, fileloc p_loc) /*@modifies p_s@*/ ;
extern void sRef_setAllocated (sRef p_s, fileloc p_loc) /*@modifies p_s@*/ ;
# define sort_isNoSort(s) ((s) == 0)
/* assume NOSORTHANDLE is #define to 0 in sort.c */
-extern /*@unused@*/ void sort_printStats(void) /*@modifies g_msgstream@*/ ;
+extern /*@unused@*/ void sort_printStats(void) /*@modifies g_warningstream@*/ ;
extern bool sort_equal (sort p_s1, sort p_s2) /*@*/ ;
extern sort sort_fromLsymbol (lsymbol p_sortid) /*@modifies internalState@*/ ;
} ;
extern void stateClauseList_checkAll (uentry p_ue)
- /*@modifies p_ue, g_msgstream@*/ ;
+ /*@modifies p_ue, g_warningstream@*/ ;
/*@constant null stateClauseList stateClauseList_undefined@*/
# define stateClauseList_undefined ((stateClauseList) 0)
# define stateClauseListBASESIZE MIDBASESIZE
extern void stateClauseList_checkEqual (uentry p_old, uentry p_unew)
- /*@modifies g_msgstream@*/ ;
+ /*@modifies g_warningstream@*/ ;
/*@iter stateClauseList_elements (sef stateClauseList x, yield exposed stateClause el); @*/
# define stateClauseList_elements(x, m_el) \
*/
extern bool transferChecks_globalDestroyed (sRef p_fref, fileloc p_loc)
- /*@modifies g_msgstream@*/ ;
+ /*@modifies g_warningstream@*/ ;
extern void transferChecks_localDestroyed (sRef p_fref, fileloc p_loc)
- /*@modifies g_msgstream@*/ ;
+ /*@modifies g_warningstream@*/ ;
extern void transferChecks_structDestroyed (sRef p_fref, fileloc p_loc)
- /*@modifies g_msgstream@*/ ;
+ /*@modifies g_warningstream@*/ ;
extern void transferChecks_assign (exprNode p_lhs, exprNode p_rhs);
extern void transferChecks_initialization (exprNode p_lhs, exprNode p_rhs);
extern void uentry_setScanfLike (uentry p_ue) /*@modifies p_ue@*/ ;
extern void uentry_setPrintfLike (uentry p_ue) /*@modifies p_ue@*/ ;
-extern void uentry_checkName (uentry p_ue) /*@modifies g_msgstream, p_ue@*/ ;
+extern void uentry_checkName (uentry p_ue) /*@modifies g_warningstream, p_ue@*/ ;
extern bool uentry_sameObject (uentry p_e1, uentry p_e2);
# define uentry_sameObject(e1,e2) ((e1) == (e2))
extern void uentry_addAccessType (uentry p_ue, typeId p_tid) /*@modifies p_ue@*/ ;
extern void uentry_showWhereAny (uentry p_spec)
- /*@modifies g_msgstream@*/ ;
+ /*@modifies g_warningstream@*/ ;
extern void uentry_checkParams (uentry p_ue);
extern void uentry_mergeUses (uentry p_res, uentry p_other);
/*@temp@*/ fileloc p_f)
/*@*/ ;
-extern void uentry_checkMatchParam (uentry p_u1, uentry p_u2, int p_paramno, exprNode p_e) /*@modifies g_msgstream@*/ ;
+extern void uentry_checkMatchParam (uentry p_u1, uentry p_u2, int p_paramno, exprNode p_e) /*@modifies g_warningstream@*/ ;
extern /*@observer@*/ stateClauseList uentry_getStateClauseList (uentry p_ue) /*@*/ ;
extern void uentry_showWhereLastExtra (uentry p_spec, /*@only@*/ cstring p_extra)
- /*@modifies g_msgstream@*/ ;
+ /*@modifies g_warningstream@*/ ;
# ifndef NOLCL
extern void uentry_setRefCounted (uentry p_e);
extern void uentry_setType (uentry p_e, ctype p_t);
extern /*@unused@*/ /*@observer@*/ cstring uentry_checkedName (uentry p_ue);
-extern void uentry_showWhereLastPlain (uentry p_spec) /*@modifies g_msgstream@*/ ;
+extern void uentry_showWhereLastPlain (uentry p_spec) /*@modifies g_warningstream@*/ ;
extern void
uentry_showWhereSpecifiedExtra (uentry p_spec, /*@only@*/ cstring p_s)
- /*@modifies g_msgstream@*/ ;
+ /*@modifies g_warningstream@*/ ;
-extern void uentry_showWhereSpecified (uentry p_spec) /*@modifies g_msgstream@*/ ;
-extern void uentry_showWhereLast (uentry p_spec) /*@modifies g_msgstream@*/ ;
-extern void uentry_showWhereDeclared (uentry p_spec) /*@modifies g_msgstream@*/ ;
+extern void uentry_showWhereSpecified (uentry p_spec) /*@modifies g_warningstream@*/ ;
+extern void uentry_showWhereLast (uentry p_spec) /*@modifies g_warningstream@*/ ;
+extern void uentry_showWhereDeclared (uentry p_spec) /*@modifies g_warningstream@*/ ;
extern /*@notnull@*/ /*@only@*/ uentry uentry_makeIdVariable (idDecl p_t) /*@*/ ;
extern uentry uentry_copy (uentry p_e) /*@*/ ;
extern void usymtab_printTypes (void)
/*@globals internalState@*/
- /*@modifies g_msgstream@*/ ;
+ /*@modifies g_warningstream@*/ ;
extern void usymtab_setMustBreak (void) /*@modifies internalState@*/ ;
extern bool usymtab_inFileScope (void) /*@globals internalState@*/ ;
extern void usymtab_checkFinalScope (bool p_isReturn)
/*@globals internalState@*/
- /*@modifies *g_msgstream@*/ ;
+ /*@modifies *g_warningstream@*/ ;
extern void usymtab_allUsed (void)
/*@globals internalState@*/
- /*@modifies *g_msgstream@*/ ;
+ /*@modifies *g_warningstream@*/ ;
extern void usymtab_allDefined (void)
/*@globals internalState@*/
- /*@modifies *g_msgstream@*/ ;
+ /*@modifies *g_warningstream@*/ ;
extern void usymtab_prepareDump (void)
/*@modifies internalState@*/ ;
extern /*@unused@*/ void usymtab_displayAllUses (void)
/*@globals internalState@*/
- /*@modifies *g_msgstream@*/ ;
+ /*@modifies *g_warningstream@*/ ;
extern /*@unused@*/ void usymtab_printOut (void)
/*@globals internalState@*/
- /*@modifies *g_msgstream@*/ ;
+ /*@modifies *g_warningstream@*/ ;
extern /*@unused@*/ void usymtab_printAll (void)
/*@globals internalState@*/
- /*@modifies *g_msgstream@*/ ;
+ /*@modifies *g_warningstream@*/ ;
extern void usymtab_enterScope (void)
/*@modifies internalState;@*/ ;
extern void usymtab_unguard (sRef p_s) /*@modifies internalState@*/ ;
extern bool usymtab_isGuarded (sRef p_s) /*@globals internalState@*/ ;
-extern void usymtab_printGuards (void) /*@globals internalState@*/ /*@modifies *g_msgstream@*/ ;
+extern void usymtab_printGuards (void) /*@globals internalState@*/ /*@modifies *g_warningstream@*/ ;
extern void usymtab_quietPlainExitScope (void) /*@modifies internalState@*/ ;
extern void usymtab_printComplete (void) /*@globals internalState@*/ /*@modifies *stdout@*/ ;
extern void usymtab_checkDistinctName (uentry p_e, int p_scope)
/*@globals internalState@*/
- /*@modifies *g_msgstream, p_e@*/ ;
+ /*@modifies *g_warningstream, p_e@*/ ;
extern /*@exposed@*/ sRef usymtab_lookupGlobalMarker (void) /*@globals internalState@*/ ;
extern void usymtab_printTypes (void)
/*@globals internalState@*/
- /*@modifies g_msgstream@*/ ;
+ /*@modifies g_warningstream@*/ ;
extern void usymtab_setMustBreak (void) /*@modifies internalState@*/ ;
extern bool usymtab_inFileScope (void) /*@globals internalState@*/ ;
extern void usymtab_checkFinalScope (bool p_isReturn)
/*@globals internalState@*/
- /*@modifies *g_msgstream@*/ ;
+ /*@modifies *g_warningstream@*/ ;
extern void usymtab_allUsed (void)
/*@globals internalState@*/
- /*@modifies *g_msgstream@*/ ;
+ /*@modifies *g_warningstream@*/ ;
extern void usymtab_allDefined (void)
/*@globals internalState@*/
- /*@modifies *g_msgstream@*/ ;
+ /*@modifies *g_warningstream@*/ ;
extern void usymtab_prepareDump (void)
/*@modifies internalState@*/ ;
extern /*@unused@*/ void usymtab_displayAllUses (void)
/*@globals internalState@*/
- /*@modifies *g_msgstream@*/ ;
+ /*@modifies *g_warningstream@*/ ;
extern /*@unused@*/ void usymtab_printOut (void)
/*@globals internalState@*/
- /*@modifies *g_msgstream@*/ ;
+ /*@modifies *g_warningstream@*/ ;
extern /*@unused@*/ void usymtab_printAll (void)
/*@globals internalState@*/
- /*@modifies *g_msgstream@*/ ;
+ /*@modifies *g_warningstream@*/ ;
extern void usymtab_enterScope (void)
/*@modifies internalState;@*/ ;
extern void usymtab_unguard (sRef p_s) /*@modifies internalState@*/ ;
extern bool usymtab_isGuarded (sRef p_s) /*@globals internalState@*/ ;
-extern void usymtab_printGuards (void) /*@globals internalState@*/ /*@modifies *g_msgstream@*/ ;
+extern void usymtab_printGuards (void) /*@globals internalState@*/ /*@modifies *g_warningstream@*/ ;
extern void usymtab_quietPlainExitScope (void) /*@modifies internalState@*/ ;
extern void usymtab_printComplete (void) /*@globals internalState@*/ /*@modifies *stdout@*/ ;
extern void usymtab_checkDistinctName (uentry p_e, int p_scope)
/*@globals internalState@*/
- /*@modifies *g_msgstream, p_e@*/ ;
+ /*@modifies *g_warningstream, p_e@*/ ;
extern /*@exposed@*/ sRef usymtab_lookupGlobalMarker (void) /*@globals internalState@*/ ;
extern void usymtab_addReallyForceMustAlias (/*@exposed@*/ sRef p_s, /*@exposed@*/ sRef p_al) /*@modifies internalState@*/ ;
{
llassert (ProcessingTypedef);
+ DPRINTF (("Declare type: %s", exprNodeList_unparse (decls)));
+
if (warnClause_isDefined (warn))
{
+ DPRINTF (("Has a warn clause!"));
+ DPRINTF (("Warn: %s", warnClause_unparse (warn)));
+
exprNodeList_elements (decls, el)
{
uentry ue = exprNode_getUentry (el);
uentry_unparse (ue), warnClause_unparse (warn)));
uentry_addWarning (ue, warnClause_copy (warn));
+ DPRINTF (("After add warning: %s", uentry_unparseFull (ue)));
cstring_free (uname);
} end_exprNodeList_elements;
}
ret->lexpr = constraintExpr_copy (l);
- if (relOp.tok == GE_OP)
+ if (lltok_getTok (relOp) == GE_OP)
+ {
ret->ar = GTE;
- else if (relOp.tok == LE_OP)
- ret->ar = LTE;
- else if (relOp.tok == EQ_OP)
- ret->ar = EQ;
+ }
+ else if (lltok_getTok (relOp) == LE_OP)
+ {
+ ret->ar = LTE;
+ }
+ else if (lltok_getTok (relOp) == EQ_OP)
+ {
+ ret->ar = EQ;
+ }
else
- llfatalbug ( message ("Unsupported relational operator"));
+ llfatalbug ( message ("Unsupported relational operator"));
ret->expr = constraintExpr_copy (r);
exprNode t, t1, t2;
lltok tok;
-
llassert (e != NULL);
data = e->edata;
constraintExpr ret;
ret = constraintExpr_makeUnaryOpConstraintExpr ( cexpr);
- switch (op.tok)
+ switch (lltok_getTok (op))
{
case QMAXSET:
ret->data = constraintExprData_unaryExprSetOp (ret->data, MAXSET);
{
constraintExpr ret;
ret = constraintExpr_makeBinaryOpConstraintExpr (expr1, expr2);
- if (op.tok == TPLUS)
- ret->data = constraintExprData_binaryExprSetOp(ret->data, BINARYOP_PLUS);
- else if (op.tok == TMINUS)
- ret->data = constraintExprData_binaryExprSetOp(ret->data, BINARYOP_MINUS);
- else
- {
- llassert(FALSE);
- }
+
+ if (lltok_getTok (op) == TPLUS)
+ {
+ ret->data = constraintExprData_binaryExprSetOp(ret->data, BINARYOP_PLUS);
+ }
+ else if (lltok_getTok (op) == TMINUS)
+ {
+ ret->data = constraintExprData_binaryExprSetOp(ret->data, BINARYOP_MINUS);
+ }
+ else
+ {
+ llassert (FALSE);
+ }
+
return ret;
}
t2 = exprData_getOpB (data);
tok = exprData_getOpTok (data);
- if (tok.tok == ADD_ASSIGN)
+ if (lltok_getTok (tok) == ADD_ASSIGN)
{
exprNode_exprTraverse (t1, TRUE, definaterv, sequencePoint);
exprNode_exprTraverse (t2, definatelv, TRUE, sequencePoint);
cons = constraint_makeAddAssign (t1, t2, sequencePoint);
e->ensuresConstraints = constraintList_add(e->ensuresConstraints, cons);
}
- else if (tok.tok == SUB_ASSIGN)
+ else if (lltok_getTok (tok) == SUB_ASSIGN)
{
exprNode_exprTraverse (t1, TRUE, definaterv, sequencePoint);
exprNode_exprTraverse (t2, definatelv, TRUE, sequencePoint);
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;
llassert (index >= 0 && index <= NUMSTRINGFLAGS);
- if (flag == FLG_SYSTEMDIRS)
+ DPRINTF (("set string: %s", flagcode_unparse (flag)));
+
+ switch (flag)
{
- llassert (cstring_isDefined (val));
+ case FLG_MESSAGESTREAM:
+ case FLG_WARNINGSTREAM:
+ case FLG_ERRORSTREAM:
+ {
+ if (cstring_isDefined (val))
+ {
+ FILE *fstream;
- 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;
+ 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");
- while (isspace ((int) cstring_getChar (tval, size_fromInt (n))))
- {
- n--;
- }
+ if (fstream == NULL)
+ {
+ llfatalerror (message ("Unable to open output stream file %s for writing",
+ val));
+ }
- 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);
- }
- }
+ /*
+ ** This ensures fstream will be closed on exit.
+ */
- 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
- {
- ;
- }
+ 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 = 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 */
+ }
}
-
+
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)));
+ ("setting %s to string beginning with \". You probably "
+ "don't meant to have the \"'s.",
+ flagcode_unparse (flag)));
}
-
- if (flag == FLG_BOOLTYPE)
- {
-
- }
-
+
gc.strings[index] = val;
}
{
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);
}
-
/*drl 12/30/01 these are some ugly functions that were added to facilitate struct annotations */
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;
-}
-
-*/
# include "cpplib.h"
# include "cpperror.h"
-static void cppReader_printFileAndLine (cppReader *p_pfile);
+static cstring cppReader_unparseLoc (cppReader *p_pfile);
+
static void cppReader_warningWithLine (cppReader *p_pfile,
int p_line, int p_column,
/*@only@*/ cstring p_msg);
int line, col;
cstring temps;
- cppBuffer_lineAndColumn (ip, &line, &col);
+ cppBuffer_getLineAndColumn (ip, &line, &col);
if (ip->fname != NULL)
{
if (first)
{
first = 0;
- fprintf (g_msgstream, " In file included");
+ fprintf (g_warningstream, " In file included");
}
else
- fprintf (g_msgstream, ",\n ");
+ fprintf (g_warningstream, ",\n ");
}
- fprintf (g_msgstream, " from %s",
+ fprintf (g_warningstream, " from %s",
cstring_toCharsSafe (temps = fileloc_unparseRaw (ip->nominal_fname, line)));
cstring_free (temps);
if (!first)
{
- fprintf (g_msgstream, "\n");
+ fprintf (g_warningstream, "\n");
}
/* Record we have printed the status as of this time. */
pfile->input_stack_listing_current = 1;
}
-static void
-cppReader_fileLineForMessage (cstring filename, long line, long column)
+static /*@only@*/ cstring
+cppReader_unparseLoc (cppReader *pfile)
{
- if (column > 0)
- {
- cstring temps;
-
- if (filename != NULL)
- {
- fprintf (stderr, "%s: ",
- cstring_toCharsSafe (temps = fileloc_unparseRawCol (filename, (int) line, (int) column)));
- }
- else
- {
- fprintf (stderr, "%s: ",
- cstring_toCharsSafe (temps = fileloc_unparseRawCol (cstring_makeLiteralTemp ("<no file>"),
- (int) line, (int) column)));
- }
-
- cstring_free (temps);
- }
- else
- {
- cstring temps;
-
- if (filename != NULL)
- {
- fprintf (stderr, "%s: ",
- cstring_toCharsSafe (temps = fileloc_unparseRaw (filename, (int) line)));
-
- }
- else
- {
- fprintf (stderr, "%s: ",
- cstring_toCharsSafe (temps = fileloc_unparseRaw (cstring_makeLiteralTemp ("<no file>"),
- (int) line)));
- }
-
- cstring_free (temps);
- }
+ DPRINTF (("unparse loc: %s",
+ fileloc_unparse (cppReader_getLoc (pfile))));
+ return (fileloc_unparse (cppReader_getLoc (pfile)));
}
/* IS_ERROR is 2 for "fatal" error, 1 for error, 0 for warning */
fid = fileTable_addFile (context_fileTable (), fname);
}
- cppBuffer_lineAndColumn (ip, &line, &col);
-
+ cppBuffer_getLineAndColumn (ip, &line, &col);
return fileloc_create (fid, line, col);
}
else
}
}
-void
-cppReader_printFileAndLine (cppReader *pfile)
-{
- cppBuffer *ip = cppReader_fileBuffer (pfile);
-
- if (ip != NULL)
- {
- int line, col;
-
- cppBuffer_lineAndColumn (ip, &line, &col);
- cppReader_fileLineForMessage (ip->nominal_fname,
- line, pfile->show_column ? col : -1);
- }
- else
- {
- fprintf (stderr, "Command Line: ");
- }
-}
-
void
cppReader_errorLit (cppReader *pfile, /*@observer@*/ cstring msg)
{
void
cppReader_error (cppReader *pfile, /*@only@*/ cstring msg)
{
- prepareMessage ();
- cppReader_printContainingFiles (pfile);
- cppReader_printFileAndLine (pfile);
- cppReader_message (pfile, 1, msg);
- closeMessage ();
+ if (cppoptgenerror (FLG_PREPROC, msg, pfile))
+ {
+ pfile->errors++;
+ }
}
/* Print error message but don't count it. */
{
if (CPPOPTIONS (pfile)->warnings_are_errors)
pfile->errors++;
-
- prepareMessage ();
- cppReader_printContainingFiles (pfile);
- cppReader_printFileAndLine (pfile);
- cppReader_message (pfile, 0, msg);
- closeMessage ();
+
+ cppoptgenerror (FLG_PREPROC, msg, pfile);
}
/* Print an error message and maybe count it. */
}
void
-cppReader_errorWithLine (cppReader *pfile, long line, long column,
- /*@only@*/ cstring msg)
+cppReader_errorWithLine (cppReader *pfile, int line, int column,
+ /*@only@*/ cstring msg)
{
- cppBuffer *ip = cppReader_fileBuffer (pfile);
-
- prepareMessage ();
- cppReader_printContainingFiles (pfile);
-
- if (ip != NULL)
- cppReader_fileLineForMessage (ip->nominal_fname, line, column);
-
- cppReader_message (pfile, 1, msg);
- closeMessage ();
+ fileloc loc = cppReader_getLoc (pfile);
+ fileloc_setLineno (loc, line);
+ fileloc_setColumn (loc, column);
+
+ cppoptgenerror (FLG_PREPROC, message ("%s: %s",
+ fileloc_unparse (loc),
+ msg),
+ pfile);
}
void
cppReader_warningWithLine (cppReader *pfile,
- int line, int column,
- /*@only@*/ cstring msg)
+ int line, int column,
+ /*@only@*/ cstring msg)
{
- cppBuffer *ip;
-
if (CPPOPTIONS (pfile)->warnings_are_errors)
pfile->errors++;
- prepareMessage ();
-
- cppReader_printContainingFiles (pfile);
-
- ip = cppReader_fileBuffer (pfile);
-
- if (ip != NULL)
- {
- cppReader_fileLineForMessage (ip->nominal_fname, line, column);
- }
-
- cppReader_message (pfile, 0, msg);
- closeMessage ();
+ cppReader_errorWithLine (pfile, line, column, msg);
}
void
void cppReader_perrorWithName (cppReader *pfile, cstring name)
{
- cppReader_message (pfile, 1,
- message ("Preprocessing error for %s: %s",
- name, lldecodeerror (errno)));
+ cppoptgenerror (FLG_PREPROC,
+ message ("%s: Preprocessing error: %s",
+ name, lldecodeerror (errno)),
+ pfile);
}
if (c != '\'')
cppReader_errorLit (pfile,
- cstring_makeLiteralTemp ("malformatted character constant"));
+ cstring_makeLiteralTemp ("malformatted character constant"));
else if (num_chars == 0)
cppReader_errorLit (pfile,
- cstring_makeLiteralTemp ("empty character constant"));
+ cstring_makeLiteralTemp ("empty character constant"));
else if (num_chars > max_chars)
{
num_chars = max_chars;
cppReader_errorLit (pfile,
- cstring_makeLiteralTemp ("character constant too long"));
+ cstring_makeLiteralTemp ("character constant too long"));
}
else if (num_chars != 1 && ! cppReader_isTraditional (pfile))
{
cppReader_warningLit (pfile,
- cstring_makeLiteralTemp ("multi-character character constant"));
+ cstring_makeLiteralTemp ("multi-character character constant"));
}
else
{
if (toktab->token == CPPREADER_ERRORTOK)
{
- cppReader_error (pfile, message ("`%s' not allowed in operand of `#if'", cstring_fromChars (tok_start)));
+ cppReader_error (pfile,
+ message ("`%s' not allowed in operand of `#if'",
+ cstring_fromChars (tok_start)));
}
op.op = toktab->token;
if ((top->flags & HAVE_VALUE) != 0)
{
cppReader_errorLit (pfile,
- cstring_makeLiteralTemp ("syntax error in #if"));
+ cstring_makeLiteralTemp ("syntax error in #if"));
goto syntax_error;
}
top->flags |= HAVE_VALUE;
&& ((top[0].flags & HAVE_VALUE) == 0))
{
cppReader_errorLit (pfile,
- cstring_makeLiteralTemp ("syntax error - missing left operand"));
+ cstring_makeLiteralTemp ("syntax error - missing left operand"));
goto syntax_error;
}
if (((top[1].flags & RIGHT_OPERAND_REQUIRED) != 0)
&& ((top[1].flags & HAVE_VALUE) == 0))
{
cppReader_errorLit (pfile,
- cstring_makeLiteralTemp ("syntax error - missing right operand"));
+ cstring_makeLiteralTemp ("syntax error - missing right operand"));
goto syntax_error;
}
/* top[0].value = (top[1].op)(v1, v2);*/
if (v2 == 0)
{
cppReader_errorLit (pfile,
- cstring_makeLiteralTemp ("Division by zero in #if"));
+ cstring_makeLiteralTemp ("Division by zero in #if"));
v2 = 1;
}
top->unsignedp = unsigned1 || unsigned2;
if (v2 == 0)
{
cppReader_errorLit (pfile,
- cstring_makeLiteralTemp ("Division by zero in #if"));
+ cstring_makeLiteralTemp ("Division by zero in #if"));
v2 = 1;
}
top->unsignedp = unsigned1 || unsigned2;
if ((top->flags & HAVE_VALUE) != 0)
{
cppReader_errorLit (pfile,
- cstring_makeLiteralTemp ("syntax error"));
+ cstring_makeLiteralTemp ("syntax error"));
goto syntax_error;
}
top->value = ~ v2;
/*@switchbreak@*/ break;
case '(': case '?':
cppReader_errorLit (pfile,
- cstring_makeLiteralTemp ("syntax error in #if"));
+ cstring_makeLiteralTemp ("syntax error in #if"));
goto syntax_error;
case ':':
if (top[0].op != '?')
{
cppReader_errorLit (pfile,
- cstring_makeLiteralTemp ("syntax error ':' without preceding '?'"));
+ cstring_makeLiteralTemp ("syntax error ':' without preceding '?'"));
goto syntax_error;
}
else if (((top[1].flags & HAVE_VALUE) == 0)
|| ((top[0].flags & HAVE_VALUE) == 0))
{
cppReader_errorLit (pfile,
- cstring_makeLiteralTemp ("bad syntax for ?: operator"));
+ cstring_makeLiteralTemp ("bad syntax for ?: operator"));
goto syntax_error;
}
else
|| ((top[-1].flags & HAVE_VALUE) != 0))
{
cppReader_errorLit (pfile,
- cstring_makeLiteralTemp ("mismatched parentheses in #if"));
+ cstring_makeLiteralTemp ("mismatched parentheses in #if"));
goto syntax_error;
}
else
if (top != stack)
{
cppReader_errorLit (pfile,
- cstring_makeLiteralTemp ("internal error in #if expression"));
+ cstring_makeLiteralTemp ("internal error in #if expression"));
}
val = top->value;
static enum cpp_token cpp_handleComment (cppReader *p_pfile,
struct parse_marker *p_smark)
- /*@modifies p_pfile, p_smark@*/;
+ /*@modifies p_pfile, p_smark@*/;
static bool cpp_shouldCheckMacro (cppReader *p_pfile, char *p_p) /*@modifies p_p@*/ ;
DPRINTF (("Create definition: %s", buf));
*limit = save;
- cppBuffer_lineAndColumn (CPPBUFFER (pfile), &line, &col);
+ cppBuffer_getLineAndColumn (CPPBUFFER (pfile), &line, &col);
bp = buf;
}
void
-cppBuffer_lineAndColumn (/*@null@*/ cppBuffer *pbuf, /*@out@*/ int *linep,
+cppBuffer_getLineAndColumn (/*@null@*/ cppBuffer *pbuf, /*@out@*/ int *linep,
/*@null@*/ /*@out@*/ int *colp)
{
int dummy;
struct argdata *args = NULL;
pfile->output_escapes++;
- cppBuffer_lineAndColumn (cppReader_fileBuffer (pfile), &start_line, &start_column);
+ cppBuffer_getLineAndColumn (cppReader_fileBuffer (pfile), &start_line, &start_column);
DPRINTF (("Expand macro: %d:%d", start_line, start_column));
nargs = defn->nargs;
** numbers accurate.
*/
- cppBuffer_lineAndColumn (cppReader_fileBuffer (pfile), &end_line, &end_column);
+ cppBuffer_getLineAndColumn (cppReader_fileBuffer (pfile), &end_line, &end_column);
DPRINTF (("Expand macro: %d:%d", end_line, end_column));
/* If macro wants zero args, we parsed the arglist for checking only.
}
newlines = 0;
- cppBuffer_lineAndColumn (cppReader_fileBuffer (pfile),
+ cppBuffer_getLineAndColumn (cppReader_fileBuffer (pfile),
&start_line, &start_column);
c = skip_comment (pfile, &newlines);
case '\'':
/* A single quoted string is treated like a double -- some
programs (e.g., troff) are perverse this way */
- cppBuffer_lineAndColumn (cppReader_fileBuffer (pfile),
- &start_line, &start_column);
+ cppBuffer_getLineAndColumn (cppReader_fileBuffer (pfile),
+ &start_line, &start_column);
old_written = cpplib_getWritten (pfile);
string:
cppReader_putChar (pfile, c);
if (context_inMacro ())
{
/* Don't use RETURN_TOK */
- yylval.tok = lltok_create (TENDMACRO, g_currentloc);
+ yylval.tok = lltok_create (TENDMACRO, fileloc_copy (g_currentloc)); /* !!! evans 2002-03-13 */
lastWasString = FALSE;
return (TENDMACRO);
}
{
if (ctbase_isUA (cte->ctbase))
{
- fprintf (g_msgstream, "%3d: %s [%d]\n", i,
+ fprintf (g_warningstream, "%3d: %s [%d]\n", i,
cstring_toCharsSafe (ctentry_doUnparse (cttab.entries[i])),
cte->ctbase->contents.tid);
}
else
{
- fprintf (g_msgstream, "%3d: %s\n", i,
+ fprintf (g_warningstream, "%3d: %s\n", i,
cstring_toCharsSafe (ctentry_doUnparse (cttab.entries[i])));
}
}
else
{
- /* fprintf (g_msgstream, "%3d: <no name>\n", i); */
+ /* fprintf (g_warningstream, "%3d: <no name>\n", i); */
}
}
/*@noaccess ctbase@*/
if (context_getFlag (FLG_SHOWSCAN) && cttab.size > 5000)
{
- fprintf (g_msgstream, " >\n"); /* end dumping to */
- fprintf (g_msgstream, "< Dumping type table (%d types) ", cttab.size);
+ displayScanClose ();
+ displayScanOpen (message ("< Dumping type table (%d types) ", cttab.size));
showdotstride = cttab.size / 5;
showdots = TRUE;
}
- /*
- DPRINTF (("Dumping cttable: "));
- cttable_print ();
- */
-
for (i = 0; i < cttab.size; i++)
{
cstring s;
if (showdots && (i != 0 && ((i - 1) % showdotstride == 0)))
{
- (void) fflush (g_msgstream);
+ (void) fflush (g_warningstream);
fprintf (stderr, ".");
(void) fflush (stderr);
}
/*@observer@*/ lltok exprData_getTok (exprData data) /*@*/
{
llassert (data != exprData_undefined);
- return (*data->tok);
+ return data->tok;
}
/*@exposed@*/ qtype exprData_getType (exprData data) /*@*/
/*@only@*/ exprData exprData_makeTok (/*@only@*/ lltok op)
{
exprData ed = (exprData) dmalloc (sizeof (*ed));
-
- ed->tok = (lltok *) dmalloc (sizeof (*(ed->tok)));
- *(ed->tok) = op;
+ ed->tok = op;
+
return ed;
}
/*@only@*/ cstring f)
{
exprNode res = exprNode_fieldAccessAux (s, lltok_getLoc (dot), f);
- lltok_release (dot);
+ lltok_free (dot);
return res;
}
/*@only@*/ cstring f)
{
exprNode res = exprNode_arrowAccessAux (s, lltok_getLoc (arrow), f);
- lltok_release (arrow);
+ lltok_free (arrow);
return res;
}
if (exprNode_isError (e))
{
qtype_free (q);
- lltok_release (tok);
+ lltok_free (tok);
return exprNode_undefined;
}
/*@access fileId*/
+static void
+fileTable_addOpen (fileTable p_ft, /*@observer@*/ FILE *p_f, /*@only@*/ cstring p_fname)
+ /*@modifies p_ft@*/ ;
+
static bool fileTable_inRange (fileTable ft, fileId fid) /*@*/
{
return (fileTable_isDefined (ft) && (fid >= 0) && (fid < ft->nentries));
}
+void
+fileTable_addStreamFile (fileTable ft, FILE *fstream, cstring name)
+{
+ fileTable_addOpen (ft, fstream, cstring_copy (name));
+}
+
bool
fileTable_isHeader (fileTable ft, fileId fid)
{
if (msg)
{
- (void) fflush (g_msgstream);
+ (void) fflush (g_warningstream);
fprintf (stderr, "< cleaning");
}
if (msg && ((i % skip) == 0))
{
- (void) fflush (g_msgstream);
+ (void) fflush (g_warningstream);
if (i == 0) {
fprintf (stderr, " ");
static /*@only@*/ flagSpecItem flagSpecItem_create (/*@only@*/ cstring fname)
{
- flagSpecItem res = (flagSpecItem) dmalloc (sizeof (*res));
+ flagSpecItem res = (flagSpecItem) dmalloc (sizeof (*res));\r
+ DPRINTF (("Creating item: [%p]", fname));\r
+ DPRINTF (("The name is: %s", fname));\r
+
res->name = fname;
res->code = flags_identifyFlag (fname);
/* Invalid flag okay for now... */
{
flagSpec res = (flagSpec) dmalloc (sizeof (*res));
res->tspec = fitem;
- res->trest = frest;
+ res->trest = frest;\r
+ DPRINTF (("New flag spec: %s", flagSpec_unparse (res)));
return res;
}
flagSpec flagSpec_createPlain (cstring fname)
{
- flagSpecItem fitem = flagSpecItem_create (fname);
- flagSpec res = flagSpec_create (fitem, flagSpec_undefined);
+ flagSpecItem fitem = flagSpecItem_create (fname);\r
+ flagSpec res = flagSpec_create (fitem, flagSpec_undefined);
+ DPRINTF (("New flag spec: %s", flagSpec_unparse (res)));\r
return res;
}
static cstringSList sortedFlags (void) /*@*/ ;
static /*@observer@*/ cstring categoryName (flagkind p_kind) /*@*/ ;
-static flagcode flags_identifyFlagAux (cstring p_s, bool p_quiet) /*@modifies g_msgstream@*/ ;
+static flagcode flags_identifyFlagAux (cstring p_s, bool p_quiet) /*@modifies g_warningstream@*/ ;
# if 0
static /*@unused@*/ cstring listModes (void) /*@*/ ;
return (flags[f].main == FK_NAMES);
}
+bool flagcode_isMessageControlFlag (flagcode f)
+{
+ /*
+ ** True if opt controls the display of messages.
+ ** These flags must be processed first.
+ */
+
+ return (f == FLG_SHOWSCAN
+ || f == FLG_WARNRC
+ || f == FLG_PARENFILEFORMAT
+ || f == FLG_MESSAGESTREAMSTDERR
+ || f == FLG_MESSAGESTREAMSTDOUT
+ || f == FLG_WARNINGSTREAMSTDERR
+ || f == FLG_WARNINGSTREAMSTDOUT
+ || f == FLG_ERRORSTREAMSTDERR
+ || f == FLG_ERRORSTREAMSTDOUT
+ || f == FLG_MESSAGESTREAM
+ || f == FLG_WARNINGSTREAM
+ || f == FLG_ERRORSTREAM
+ || f == FLG_STREAMOVERWRITE);
+}
+
/*
** Internal consistency check on the flags.
*/
res = SKIP_FLAG;
}
+ else if (cstring_equalLit (cflag, "usestderr"))
+ {
+ if (!quiet)
+ {
+ llerror_flagWarning
+ (cstring_makeLiteral
+ ("usestderr flag is obsolete. This has been replaced "
+ "by more precise flags for controlling the warning, "
+ "status message and fatal error streams independently: message-stream-stdout, "
+ "message-stream-stderr, message-stream <file>, "
+ "warning-stream-stdout, warning-stream-stderr, warning-stream <file>, "
+ "error-stream-stdout, error-stream-stderr, error-stream <file>."));
+ }
+
+ res = SKIP_FLAG;
+ }
+
else if (cstring_equalLit (cflag, "stdio"))
{
if (!quiet)
FK_SYNTAX, FK_PREPROC, plainFlag,
"preproc",
FLG_PREPROC,
- "preprocessing error", NULL,
+ "preprocessing error",
+ "Preprocessing error.",
0, 0
},
"suppress herald and error count",
NULL, 0, 0
},
+
+ /*
+ ** Default is to send messages, warnings and errors to stderr
+ */
+
{
- FK_DISPLAY, FK_ERRORS, plainFlag,
- "usestderr",
- FLG_USESTDERR,
- "send error messages to standard error (instead of standard out)",
+ FK_DISPLAY, FK_ERRORS, idemGlobalFlag,
+ "messagestreamstdout",
+ FLG_MESSAGESTREAMSTDOUT,
+ "send status messages to standard output stream",
NULL, 0, 0
},
+ {
+ FK_DISPLAY, FK_ERRORS, idemGlobalFlag,
+ "messagestreamstderr",
+ FLG_MESSAGESTREAMSTDERR,
+ "send status messages to standard error stream",
+ NULL, 0, 0
+ },
+ {
+ FK_DISPLAY, FK_ERRORS, globalStringFlag, ARG_FILE,
+ "messagestream",
+ FLG_MESSAGESTREAM,
+ "send status messages to <file>",
+ NULL, 0, 0
+ },
+
+ {
+ FK_DISPLAY, FK_ERRORS, idemGlobalFlag,
+ "warningstreamstdout",
+ FLG_WARNINGSTREAMSTDOUT,
+ "send warnings to standard output stream",
+ NULL, 0, 0
+ },
+ {
+ FK_DISPLAY, FK_ERRORS, idemGlobalFlag,
+ "warningstreamstderr",
+ FLG_WARNINGSTREAMSTDERR,
+ "send warnings to standard error stream",
+ NULL, 0, 0
+ },
+ {
+ FK_DISPLAY, FK_ERRORS, globalStringFlag, ARG_FILE,
+ "warningstream",
+ FLG_WARNINGSTREAM,
+ "send warnings to <file>",
+ NULL, 0, 0
+ },
+
+ {
+ FK_DISPLAY, FK_ERRORS, idemGlobalFlag,
+ "errorstreamstdout",
+ FLG_ERRORSTREAMSTDOUT,
+ "send fatal errors to standard output stream",
+ NULL, 0, 0
+ },
+ {
+ FK_DISPLAY, FK_ERRORS, idemGlobalFlag,
+ "errorstreamstderr",
+ FLG_ERRORSTREAMSTDERR,
+ "send fatal errors to standard error stream",
+ NULL, 0, 0
+ },
+ {
+ FK_DISPLAY, FK_ERRORS, globalStringFlag, ARG_FILE,
+ "errorstream",
+ FLG_ERRORSTREAM,
+ "send fatal errors to <file>",
+ NULL, 0, 0
+ },
+
+ {
+ FK_DISPLAY, FK_ERRORS, globalFlag,
+ "streamoverwrite",
+ FLG_STREAMOVERWRITE,
+ "warn and exit if a stream output file would overwrite an existing file",
+ NULL, 0, 0
+ },
+
+
{
FK_DISPLAY, FK_ERRORS, plainFlag,
"showsummary",
cstring g_prevCodeFile = cstring_undefined;
int g_prevCodeLine = 0;
-/*:open:*/ FILE *g_msgstream;
+
+/*
+** These are initialized in llmain.c.
+*/
+
+FILE *g_warningstream = NULL;
+FILE *g_messagestream = NULL;
+FILE *g_errorstream = NULL;
/*
** These were in llmain.c. Most should not be globals...
{
globalsClause res = (globalsClause) dmalloc (sizeof (*res));
res->globs = gl;
- res->loc = lltok_stealLoc (tok);
+ res->loc = fileloc_copy (lltok_getLoc (tok));
/*@i423@*/ return res; /* releases doesn't seem to work right here... */
}
static void
LocalUserError (/*@unused@*/ ltoken p_t, /*@temp@*/ char *p_msg)
- /*@modifies *g_msgstream@*/ ;
+ /*@modifies *g_warningstream@*/ ;
/* If TRUE character has been redefined as a singleChar. */
static bool defineSingleChar[LASTCHAR + 1];
static void printDot (void)
{
- if (context_getFlag (FLG_SHOWSCAN))
- {
- (void) fflush (g_msgstream);
- fprintf (stderr, ".");
- (void) fflush (stderr);
- }
+ displayScanContinue (cstring_makeLiteralTemp ("."));
}
void
f = fileTable_openFile (context_fileTable (), fname, "w");
- if (context_getFlag (FLG_SHOWSCAN))
- {
- fprintf (stderr, "< Dumping to %s ", cstring_toCharsSafe (fname));
- }
+ displayScanOpen (message ("Dumping to %s ", fname));
if (f == NULL)
{
check (fileTable_closeFile (context_fileTable (), f));
}
- if (context_getFlag (FLG_SHOWSCAN))
- {
- fprintf (g_msgstream, " >\n");
- }
-
+ displayScanClose ();
cstring_free (fname);
}
DPRINTF (("Loading: %s", fpath));
- if (context_getDebug (FLG_SHOWSCAN))
- {
- fprintf (g_msgstream, "< loading standard library %s ",
- cstring_toCharsSafe (fpath));
- result = loadLCDFile (stdlib, fpath);
- fprintf (g_msgstream, " >\n");
- }
- else
- {
- result = loadLCDFile (stdlib, fpath);
- }
+ displayScanOpen (message ("loading standard library %s ", fpath));
+ result = loadLCDFile (stdlib, fpath);
+ displayScanClose ();
check (fileTable_closeFile (context_fileTable (), stdlib));
}
if (f == NULL)
{
- if (context_getDebug (FLG_SHOWSCAN))
- fprintf (g_msgstream, " >\n");
-
+ displayScanClose ();
llfatalerror (message ("Cannot open dump file for loading: %s",
fname));
}
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 ();
}
}
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 (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 ();
lclfatalbug (char *msg)
{
prepareMessage ();
- printError (stderr,
+ printError (g_errorstream,
message ("*** Fatal Bug: %s", cstring_fromChars (msg)));
printCodePoint ();
printBugReport ();
{
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 ();
+
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;
}
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
llfatalerror (cstring s)
{
prepareMessage ();
- printError (stderr, s);
- printError (stderr, cstring_makeLiteral ("*** Cannot continue."));
+ printError (g_errorstream, s);
+ printError (g_errorstream, cstring_makeLiteral ("*** Cannot continue."));
llexit (LLFAILURE);
}
llfatalerrorLoc (/*@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."));
+ (void) fflush (g_warningstream);
llexit (LLFAILURE);
}
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);
}
{
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)
# 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)
+{
+ llassert (!s_scanOpen);
+
+ if (context_getFlag (FLG_SHOWSCAN))
+ {
+ fprintf (g_messagestream, "< %s >\n", cstring_toCharsSafe (msg));
+ (void) fflush (g_messagestream);
+ }
+
+ cstring_free (msg);
+}
+
+void displayScanOpen (cstring msg)
+{
+ 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))
+ {
+ llassert (s_scanOpen);
+ fprintf (g_messagestream, "%s", cstring_toCharsSafe (msg));
+ (void) fflush (g_messagestream);
+ }
+}
+
+void displayScanClose (void)
+{
+ llassert (s_scanOpen);
+
+ if (context_getFlag (FLG_SHOWSCAN))
+ {
+ fprintf (g_messagestream, " >\n");
+ (void) fflush (g_messagestream);
+ }
+
+ s_scanOpen = FALSE;
}
+
+
/*@=noparams@*/
/*@-redecl@*/
-void ylerror (char *) /*@modifies *g_msgstream@*/ ;
+void ylerror (char *) /*@modifies *g_warningstream@*/ ;
/*@=redecl@*/
bool g_inTypeDef = FALSE;
/*@=noparams@*/
/*@-redecl@*/
-void ylerror (char *) /*@modifies *g_msgstream@*/ ;
+void ylerror (char *) /*@modifies *g_warningstream@*/ ;
/*@=redecl@*/
bool g_inTypeDef = FALSE;
setSpecFileId (fid);
- if (context_getFlag (FLG_SHOWSCAN))
- {
- lldiagmsg (message ("< reading spec %s >", g_currentSpec));
- }
+ displayScan (message ("reading spec %s", g_currentSpec));
/* Open the source file */
void showHerald (void)
{
- if (hasShownHerald || context_getFlag (FLG_QUIET)) return;
-
+ if (hasShownHerald || context_getFlag (FLG_QUIET))
+ {
+ return;
+ }
else
{
- fprintf (g_msgstream, "%s\n\n", SPLINT_VERSION);
+ fprintf (g_messagestream, "%s\n\n", SPLINT_VERSION);
hasShownHerald = TRUE;
llflush ();
}
# ifdef NOLCL
/*@globals killed undef g_currentloc,
killed undef yyin,
- undef g_msgstream;
+ undef g_warningstream, g_messagestream, g_errorstream;
@*/
/*@modifies g_currentloc, fileSystem,
yyin;
killed undef g_currentSpec,
killed undef g_currentSpecName,
killed undef yyin,
- undef g_msgstream;
+ undef g_warningstream, g_messagestream, g_errorstream;
@*/
/*@modifies g_currentloc, initFile,
g_localSpecPath, g_currentSpec, g_currentSpecName, fileSystem,
_wildcard (&argc, &argv);
# endif
- g_msgstream = stdout;
+ g_warningstream = stdout;
+ g_messagestream = stderr;
+ g_errorstream = stderr;
(void) signal (SIGINT, interrupt);
(void) signal (SIGSEGV, interrupt);
setCodePoint ();
g_currentloc = fileloc_createBuiltin ();
-
+
before = clock ();
context_initMod ();
{
nof = TRUE;
}
- else if (opt == FLG_SHOWSCAN || opt == FLG_WARNRC || opt == FLG_PARENFILEFORMAT)
+ else if (flagcode_isMessageControlFlag (opt))
{
/*
** Need to set it immediately, so rc file scan is displayed
*/
context_userSetFlag (opt, set);
+
+ if (flagcode_hasArgument (opt))
+ {
+ llassert (flagcode_hasString (opt));
+
+ if (++i < argc)
+ {
+ fname = cstring_fromChars (argv[i]);
+ setStringFlag (opt, fname);
+ }
+ else
+ {
+ llfatalerror
+ (message
+ ("Flag %s must be followed by a string",
+ flagcode_unparse (opt)));
+ }
+ }
}
else if (opt == FLG_OPTF)
{
opt = flags_identifyFlag (flagname);
DPRINTF (("Flag: %s", flagcode_unparse (opt)));
- if (flagcode_isSkip (opt) || opt == FLG_SHOWSCAN || opt == FLG_WARNRC || opt == FLG_PARENFILEFORMAT)
+ if (flagcode_isMessageControlFlag (opt))
{
- /* showscan already processed */
- DPRINTF (("Skipping!"));
+ /*
+ ** Processed on first pass
+ */
+
+ if (flagcode_hasArgument (opt))
+ {
+ ++i;
+ }
}
else if (flagcode_isInvalid (opt))
{
{
showHelp ();
}
- fprintf (g_msgstream, "\n");
+ fprintf (g_warningstream, "\n");
fileIdList_free (cfiles);
fileIdList_free (xfiles);
{
cstring m = context_getMerge ();
- if (context_getFlag (FLG_SHOWSCAN))
- {
- fprintf (g_msgstream, "< loading %s ", cstring_toCharsSafe (m));
- }
-
+ displayScanOpen (message ("< loading %s ", m));
loadState (m);
-
- if (context_getFlag (FLG_SHOWSCAN))
- {
- fprintf (g_msgstream, " >\n");
- }
+ displayScanClose ();
if (!usymtab_existsType (context_getBoolName ()))
{
fileIdList_elements (mtfiles, mtfile)
{
context_setFileId (mtfile);
-
- if (context_getFlag (FLG_SHOWSCAN))
- {
- lldiagmsg (message ("< processing %s >", fileTable_rootFileName (mtfile)));
- }
-
+ displayScan (message ("processing %s", fileTable_rootFileName (mtfile)));
mtreader_readFile (cstring_copy (fileTable_fileName (mtfile)));
} end_fileIdList_elements;
llflush ();
- if (context_getFlag (FLG_SHOWSCAN))
- {
- fprintf (stderr, "< preprocessing");
- }
+ displayScanOpen (cstring_makeLiteral ("preprocessing"));
lcltime = clock ();
fileIdList_free (cfiles);
- if (context_getFlag (FLG_SHOWSCAN))
- {
- fprintf (stderr, " >\n");
- }
-
+ displayScanClose ();
pptime = clock ();
}
else
llassert (yyin != NULL);
- if (context_getFlag (FLG_SHOWSCAN))
- {
- lldiagmsg (message ("< checking %q >", osd_outputPath (fileTable_rootFileName (fid))));
- }
+ displayScan (message ("checking %q", osd_outputPath (fileTable_rootFileName (fid))));
/*
** Every time, except the first time, through the loop,
** is this correct behaviour?
*/
- if (context_getFlag (FLG_SHOWSCAN))
- {
- lldiagmsg (cstring_makeLiteral ("< global checks >"));
- }
+ displayScan (cstring_makeLiteral ("global checks"));
cleanupMessages ();
expsuccess = TRUE;
if (context_neednl ())
- fprintf (g_msgstream, "\n");
+ fprintf (g_warningstream, "\n");
# ifndef NOLCL
if (nspecErrors > 0)
if (specLines > 0)
{
- fprintf (g_msgstream, "%d spec, ", specLines);
+ fprintf (g_warningstream, "%d spec, ", specLines);
}
# ifndef CLOCKS_PER_SEC
- fprintf (g_msgstream, "%d source lines in %ld time steps (steps/sec unknown)\n",
+ fprintf (g_warningstream, "%d source lines in %ld time steps (steps/sec unknown)\n",
context_getLinesProcessed (),
(long) ttime);
# else
- fprintf (g_msgstream, "%d source lines in %.2f s.\n",
+ fprintf (g_warningstream, "%d source lines in %.2f s.\n",
context_getLinesProcessed (),
(double) ttime / CLOCKS_PER_SEC);
# endif
switch (i)
{
case SIGINT:
- fprintf (stderr, "*** Interrupt\n");
+ fprintf (g_errorstream, "*** Interrupt\n");
llexit (LLINTERRUPT);
case SIGSEGV:
{
/* Cheat when there are parse errors */
checkParseError ();
- fprintf (stderr, "*** Segmentation Violation\n");
+ fprintf (g_errorstream, "*** Segmentation Violation\n");
/* Don't catch it if fileloc_unparse causes a signal */
(void) signal (SIGSEGV, NULL);
loc = fileloc_unparse (g_currentloc);
- fprintf (stderr, "*** Location (not trusted): %s\n",
+ fprintf (g_errorstream, "*** Location (not trusted): %s\n",
cstring_toCharsSafe (loc));
cstring_free (loc);
printCodePoint ();
- fprintf (stderr, "*** Please report bug to %s\n", SPLINT_MAINTAINER);
+ fprintf (g_errorstream, "*** Please report bug to %s\n", SPLINT_MAINTAINER);
exit (LLGIVEUP);
}
default:
- fprintf (stderr, "*** Signal: %d\n", i);
+ fprintf (g_errorstream, "*** Signal: %d\n", i);
/*@-mustfree@*/
- fprintf (stderr, "*** Location (not trusted): %s\n",
+ fprintf (g_errorstream, "*** Location (not trusted): %s\n",
cstring_toCharsSafe (fileloc_unparse (g_currentloc)));
/*@=mustfree@*/
printCodePoint ();
- fprintf (stderr, "*** Please report bug to %s ***\n", SPLINT_MAINTAINER);
+ fprintf (g_errorstream, "*** Please report bug to %s ***\n", SPLINT_MAINTAINER);
exit (LLGIVEUP);
}
}
if (context_getFlag (FLG_KEEP))
{
- check (fputs ("Temporary files kept:\n", stderr) != EOF);
+ check (fputs ("Temporary files kept:\n", g_messagestream) != EOF);
fileTable_printTemps (context_fileTable ());
}
else
fileloc fc = g_currentloc;
g_currentloc = fileloc_createRc (fname);
- if (context_getFlag (FLG_SHOWSCAN))
- {
- lldiagmsg (message ("< reading options from %q >",
- fileloc_outputFilename (g_currentloc)));
- }
+ displayScan (message ("< reading options from %q >",
+ fileloc_outputFilename (g_currentloc)));
loadrc (innerf, passThroughArgs);
fileloc_reallyFree (g_currentloc);
if ((filesprocessed % skip) == 0)
{
if (filesprocessed == 0) {
- fprintf (stderr, " ");
+ fprintf (g_messagestream, " ");
}
else {
- fprintf (stderr, ".");
+ fprintf (g_messagestream, ".");
}
- (void) fflush (stderr);
+ (void) fflush (g_messagestream);
}
filesprocessed++;
}
bool
lltok_isSemi (lltok tok)
{
- return (tok.tok == TSEMI);
+ return (tok->tok == TSEMI);
}
bool
lltok_isMult (lltok tok)
{
- return (tok.tok == TMULT);
+ return (tok->tok == TMULT);
}
bool lltok_isInc_Op (lltok tok)
{
- return (tok.tok == INC_OP);
+ return (tok->tok == INC_OP);
}
bool lltok_isDec_Op (lltok tok)
{
- return (tok.tok == DEC_OP);
+ return (tok->tok == DEC_OP);
}
/* DRL added this function 10/23/2000 for boolean stuff */
bool lltok_isEq_Op (lltok tok)
{
- return (tok.tok == EQ_OP);
+ return (tok->tok == EQ_OP);
}
/* DRL added this function 10/25/2000 for boolean stuff */
bool lltok_isAnd_Op (lltok tok)
{
- return (tok.tok == AND_OP);
+ return (tok->tok == AND_OP);
}
bool lltok_isOr_Op (lltok tok)
{
- return (tok.tok == OR_OP);
+ return (tok->tok == OR_OP);
}
bool lltok_isNot_Op (lltok tok)
{
- return (tok.tok == TEXCL);
+ return (tok->tok == TEXCL);
}
/*drl7x added this function 11/20/00 */
bool lltok_isLt_Op (lltok tok)
{
- return (tok.tok == TLT);
+ return (tok->tok == TLT);
}
bool lltok_isGt_Op (lltok tok)
{
- return (tok.tok == TGT);
+ return (tok->tok == TGT);
}
bool lltok_isGe_Op (lltok tok)
{
- return (tok.tok == GE_OP);
+ return (tok->tok == GE_OP);
}
bool lltok_isLe_Op (lltok tok)
{
- return (tok.tok == LE_OP);
+ return (tok->tok == LE_OP);
}
/* end drl7x added */
/*drl7x added 11 30 2000*/
bool lltok_isPlus_Op (lltok tok)
{
- return (tok.tok == TPLUS);
+ return (tok->tok == TPLUS);
}
bool lltok_isMinus_Op (lltok tok)
{
- return (tok.tok == TMINUS);
+ return (tok->tok == TMINUS);
}
/*drl7x added 6 6 2001 */
bool lltok_isAmpersand_Op (lltok tok)
{
- return (tok.tok == TAMPERSAND);
+ return (tok->tok == TAMPERSAND);
}
/*end drl added */
bool lltok_isExcl_Op (lltok tok)
{
- return (tok.tok == TEXCL);
+ return (tok->tok == TEXCL);
}
bool lltok_isTilde_Op (lltok tok)
{
- return (tok.tok == TTILDE);
+ return (tok->tok == TTILDE);
}
/*end drl added */
bool lltok_isEnsures (lltok tok)
{
- return (tok.tok == QPOSTCLAUSE);
+ return (tok->tok == QPOSTCLAUSE);
}
bool lltok_isRequires (lltok tok)
{
- return (tok.tok == QPRECLAUSE);
+ return (tok->tok == QPRECLAUSE);
}
cstring
{
char *lit;
- switch (tok.tok)
+ switch (tok->tok)
{
case BREAK: lit = "break"; break;
case CASE: lit = "case"; break;
case TRPAREN: lit = ")"; break;
case TLSQBR: lit = "["; break;
case TRSQBR: lit = "]"; break;
- case TDOT: lit = "."; break;
+ case TDOT: lit = "->"; break;
case TAMPERSAND: lit = "&"; break;
case TEXCL: lit = "!"; break;
case TTILDE: lit = "~"; break;
lltok
lltok_create (int tok, fileloc loc)
{
- lltok l;
-
- l.tok = tok;
- l.loc = loc;
+ lltok l = (lltok) dmalloc (sizeof (*l));
+ l->tok = tok;
+ l->loc = loc;
+ DPRINTF (("Create: %s [%p]", lltok_unparse (l), loc));
return (l);
}
-void lltok_release (lltok t)
+void lltok_free (lltok t)
{
- fileloc_free (t.loc);
+ fileloc_free (t->loc);
+ sfree (t);
}
-fileloc lltok_stealLoc (lltok t)
-{
- fileloc res = t.loc;
- t.loc = fileloc_undefined;
- return res;
-}
#endif
static void LocalUserError (ltoken p_t, /*@temp@*/ char *p_msg)
- /*@modifies *g_msgstream@*/;
+ /*@modifies *g_warningstream@*/;
static /*@only@*/ ltoken nextToken;
}
else
{
- if (context_getFlag (FLG_SHOWSCAN))
+ if (!fileloc_isLib (fl))
{
- if (!fileloc_isLib (fl))
- {
- lldiagmsg (message ("< checking macros %q >",
- fileloc_outputFilename (fl)));
- }
+ displayScan (message ("checking macros %q",
+ fileloc_outputFilename (fl)));
}
lastfl = fl;
res->srs = sRefSet_undefined;
res->loc = fileloc_copy (lltok_getLoc (tok));
- lltok_release (tok);
+ lltok_free (tok);
return res;
}
res->srs = rfs;
res->loc = fileloc_copy (lltok_getLoc (tok));
- lltok_release (tok);
+ lltok_free (tok);
return res;
}
}
context_setFileId (fid);
-
- if (context_getFlag (FLG_SHOWSCAN))
- {
- lldiagmsg (message ("< reading metastate %s >", fname));
- }
+ displayScan (message ("reading metastate %s", fname));
mtscanner_reset (sourceFile);
context_enterMTfile ();
# include "nameChecks.h"
static bool checkCzechName (uentry p_ue, flagcode p_czechflag, bool p_report)
- /*@modifies p_ue, g_msgstream@*/ ;
+ /*@modifies p_ue, g_warningstream@*/ ;
static bool checkSlovakName (uentry p_ue, flagcode p_slovakflag, bool p_report)
- /*@modifies p_ue, g_msgstream@*/ ;
+ /*@modifies p_ue, g_warningstream@*/ ;
static cstring czechPrefix (cstring name)
{
{
cstring s = usymIdSet_unparse (tistable[i]);
- fprintf (g_msgstream, "%d: %s\n", i, cstring_toCharsSafe (s));
+ fprintf (g_warningstream, "%d: %s\n", i, cstring_toCharsSafe (s));
cstring_free (s);
}
}
static void uentry_checkIterArgs (uentry p_ue);
static cstring uentry_dumpAux (uentry p_v, bool p_isParam);
-static void uentry_showWhereLastKind (uentry p_spec) /*@modifies g_msgstream@*/ ;
+static void uentry_showWhereLastKind (uentry p_spec) /*@modifies g_warningstream@*/ ;
static void uentry_combineModifies (uentry p_ue, /*@owned@*/ sRefSet p_sr)
/*@modifies p_ue@*/ ;
paramTypeError (/*@notnull@*/ uentry p_old, /*@notnull@*/ uentry p_oldCurrent,
ctype p_oldType, /*@notnull@*/ uentry p_unew,
/*@notnull@*/ uentry p_newCurrent,
- ctype p_newType, int p_paramno) /*@modifies g_msgstream@*/ ;
+ ctype p_newType, int p_paramno) /*@modifies g_warningstream@*/ ;
static /*@only@*/ /*@notnull@*/ uentry
uentry_makeVariableAux (cstring p_n, ctype p_t, /*@keep@*/ fileloc p_f,
static /*@exposed@*/ /*@dependent@*/ uentry
usymtab_lookupQuietNoAlt (usymtab p_s, cstring p_k);
-static void usymtab_printAllAux (usymtab p_s) /*@modifies g_msgstream@*/ ;
+static void usymtab_printAllAux (usymtab p_s) /*@modifies g_warningstream@*/ ;
static int usymtab_getIndex (/*@notnull@*/ usymtab p_s, cstring p_k);
static /*@exposed@*/ uentry usymtab_fetchIndex (/*@notnull@*/ usymtab p_s, int p_i);
static /*@exposed@*/ uentry
{
if (sRef_hasDerived (uentry_getSref (ue)))
{
- fprintf (g_msgstream, "Derived Global: %s\n", uentry_unparse (ue));
- fprintf (g_msgstream, "sRef: %s\n", sRef_unparseFull (ue->sref));
+ fprintf (g_warningstream, "Derived Global: %s\n", uentry_unparse (ue));
+ fprintf (g_warningstream, "sRef: %s\n", sRef_unparseFull (ue->sref));
}
} end_usymtab_entries ;
int depth = 0;
char *ind = mstring_copy (" ");
- fprintf (g_msgstream, "<<< [symbol table] >>>\n");
+ fprintf (g_warningstream, "<<< [symbol table] >>>\n");
while (s != GLOBAL_ENV && s->env != GLOBAL_ENV)
{
ind[depth * 3 + 1] = '\0';
}
- fprintf (g_msgstream, "level: %d (%s)\n", s->lexlevel,
+ fprintf (g_warningstream, "level: %d (%s)\n", s->lexlevel,
cstring_toCharsSafe (tname));
cstring_free (tname);
for (i = 0; i < s->nentries; i++)
{
cstring us = uentry_unparseFull (s->entries[i]);
- fprintf (g_msgstream, "%s\n", cstring_toCharsSafe (us));
+ fprintf (g_warningstream, "%s\n", cstring_toCharsSafe (us));
cstring_free (us);
}
if (s->reftable != NULL && s->nentries > 0)
{
- fprintf (g_msgstream, "\t<< Ref table >>\n");
+ fprintf (g_warningstream, "\t<< Ref table >>\n");
for (i = 0; i < s->nentries; i++)
{
- fprintf (g_msgstream, "\t%s %3d: %d, %d\n", ind, i,
+ fprintf (g_warningstream, "\t%s %3d: %d, %d\n", ind, i,
s->reftable[i]->level,
s->reftable[i]->index);
}
depth++;
s = s->env;
}
- fprintf (g_msgstream, "<<< end usymtab >>>\n");
+ fprintf (g_warningstream, "<<< end usymtab >>>\n");
mstring_free (ind);
return;
}
static void
usymtab_printAllAux (usymtab s)
- /*@modifies g_msgstream@*/
+ /*@modifies g_warningstream@*/
{
int i;
int depth = 0;
static bool checkDistinctExternalName (uentry e)
/*@globals globtab@*/
- /*@modifies *g_msgstream@*/
+ /*@modifies *g_warningstream@*/
{
size_t checklen = size_fromInt (context_getValue (FLG_EXTERNALNAMELEN));
bool ignorecase = context_getFlag (FLG_EXTERNALNAMECASEINSENSITIVE);
static bool checkDistinctInternalName (uentry e)
/*@globals utab@*/
- /*@modifies *g_msgstream@*/
+ /*@modifies *g_warningstream@*/
{
usymtab ttab = utab;
cstring name = uentry_rawName (e);
res->flag = flag;
res->msg = msg;
+ DPRINTF (("Creating warn clause with flag spec: [%p] %s", flag,
+ flagSpec_unparse (flag)));
return res;
}
extern warnClause warnClause_create (lltok tok, flagSpec flag, cstring msg)
{
warnClause res;
- res = warnClause_createAux (lltok_stealLoc (tok), flag, msg);
- lltok_release (tok);
+ /*
+ ** evans 2002-03-11
+ ** was
+ ** res = warnClause_createAux (lltok_stealLoc (tok), flag, msg);
+ ** but this leads to unexplained (yet) crashes.
+ ** Reported by Walter Briscoe
+ */
+
+ res = warnClause_createAux (fileloc_copy (lltok_getLoc (tok)), flag, msg);
+ lltok_free (tok);
return res;
}
(ISO99:7.26.3)
ansireserved.c:1:5: Name decimal_point is reserved for the standard library
ansireserved.c:2:5: Function srand inconsistently declared as variable: int
- load file standard.lcd:898:1: Specification of srand as function:
+ load file standard.lcd:899:1: Specification of srand as function:
[function (unsigned int) returns void]
ansireserved.c:2:5: Name srand is reserved for the standard library
ansireserved.c:3:5: Function labs inconsistently declared as variable: int
- load file standard.lcd:920:1: Specification of labs as function:
+ load file standard.lcd:921:1: Specification of labs as function:
[function (long int) returns long int]
ansireserved.c:3:5: Name labs is reserved for the standard library
ansireserved.c:4:5: Name _x is in the implementation name space (any identifier
decl.c:3:21: Structure struct tm declared with fields { int x; }, specified
with fields { int tm_sec; int tm_min; int tm_hour;, ... }
- load file standard.lcd:962:1: Specification of struct tm
+ load file standard.lcd:963:1: Specification of struct tm
decl.c:3:17: Field tm_sec in specified corresponds to x in declaration
load file standard.lcd:638:1: Specification of tm_sec
Cannot open file: DBL_MANT_DIG=25.c
Cannot open file: source.c
-Finished checking --- no code processed
+Finished checking --- 1 code warning, as expected
$(SPLINT) alignof.c -expect 2
source:
- $(SPLINT) -D DBL_MANT_DIG=25 source.c
+ $(SPLINT) -D DBL_MANT_DIG=25 source.c -expect 1