From 80489f0ab878fa01f87a35988aedff282e5f0ea5 Mon Sep 17 00:00:00 2001 From: evans1629 Date: Wed, 13 Mar 2002 22:30:18 +0000 Subject: [PATCH] o Make lltok an abstract type, a pointer to structure instead of a plain struct. There are still some memory leaks in the parser --- all tokens should be deallocated. o Added messagestream, warningstream and errorstream control flags so each type of message can be directed to a different stream: messagestreamstdout messagestreamstderr messagestream --- src/Headers/aliasTable.h | 2 +- src/Headers/context.h | 5 +- src/Headers/cpperror.h | 4 +- src/Headers/cpplib.h | 4 +- src/Headers/exprNode.h | 4 +- src/Headers/fileTable.h | 7 +- src/Headers/filelocStack.h | 2 +- src/Headers/flagMarkerList.h | 2 +- src/Headers/flag_codes.h | 2 +- src/Headers/flags.h | 33 ++-- src/Headers/globals.h | 12 +- src/Headers/llerror.h | 142 ++++++++++------- src/Headers/llgrammar.h | 2 +- src/Headers/llmain.h | 4 +- src/Headers/lltok.h | 13 +- src/Headers/nameChecks.h | 14 +- src/Headers/sRef.h | 12 +- src/Headers/sort.h | 2 +- src/Headers/stateClauseList.h | 4 +- src/Headers/transferChecks.h | 6 +- src/Headers/uentry.h | 18 +-- src/Headers/usymtab-branch.h | 18 +-- src/Headers/usymtab.h | 18 +-- src/clabstract.c | 6 + src/constraint.c | 18 ++- src/constraintExpr.c | 25 +-- src/constraintGeneration.c | 4 +- src/context.c | 278 +++++++++++++++++----------------- src/cpperror.c | 145 +++++------------- src/cppexp.c | 34 +++-- src/cpplib.c | 16 +- src/cscanner.l | 2 +- src/cttable.i | 17 +-- src/exprData.c | 7 +- src/exprNode.c | 6 +- src/fileTable.c | 14 +- src/flagSpec.c | 13 +- src/flags.c | 41 ++++- src/flags.def | 84 +++++++++- src/globals.c | 9 +- src/globalsClause.c | 2 +- src/lclinit.c | 2 +- src/lcllib.c | 36 +---- src/llerror.c | 246 ++++++++++++++++++------------ src/llgrammar.c.der | 2 +- src/llgrammar.y | 2 +- src/llmain.c | 134 ++++++++-------- src/lltok.c | 61 ++++---- src/lslinit.c | 2 +- src/macrocache.c | 9 +- src/modifiesClause.c | 4 +- src/mtreader.c | 6 +- src/nameChecks.c | 4 +- src/typeIdSet.c | 2 +- src/uentry.c | 4 +- src/usymtab.c | 24 +-- src/warnClause.c | 14 +- test/ansireserved.expect | 4 +- test/tests2.2.expect | 2 +- test/tests2.4.expect | 2 +- test/tests2.4/Makefile | 2 +- 61 files changed, 869 insertions(+), 744 deletions(-) diff --git a/src/Headers/aliasTable.h b/src/Headers/aliasTable.h index be50060..98249b9 100644 --- a/src/Headers/aliasTable.h +++ b/src/Headers/aliasTable.h @@ -68,7 +68,7 @@ extern aliasTable 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, diff --git a/src/Headers/context.h b/src/Headers/context.h index bf036a7..d26ccf7 100644 --- a/src/Headers/context.h +++ b/src/Headers/context.h @@ -172,9 +172,6 @@ extern /*@observer@*/ cstring context_getString (flagcode p_flag) /*@*/ ; 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) /*@*/ ; @@ -303,7 +300,7 @@ extern bool context_inMacroFunction (void) /*@globals internalState@*/ ; 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@*/ ; diff --git a/src/Headers/cpperror.h b/src/Headers/cpperror.h index 2c1861f..eb025aa 100644 --- a/src/Headers/cpperror.h +++ b/src/Headers/cpperror.h @@ -16,7 +16,7 @@ cppReader_pedwarnWithLine (cppReader *p_pfile, int p_line, int p_column, 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); @@ -24,7 +24,7 @@ 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); diff --git a/src/Headers/cpplib.h b/src/Headers/cpplib.h index cf8529b..28b3b91 100644 --- a/src/Headers/cpplib.h +++ b/src/Headers/cpplib.h @@ -537,8 +537,8 @@ struct if_stack { }; 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); diff --git a/src/Headers/exprNode.h b/src/Headers/exprNode.h index 93ed2c2..f9ff80c 100644 --- a/src/Headers/exprNode.h +++ b/src/Headers/exprNode.h @@ -119,7 +119,7 @@ typedef /*@null@*/ union { cstring literal; cstring id; - lltok *tok; + lltok tok; qtype qt; /* sizeof(type) */ /* use for any 2-operator (comma, arrayFetch, case, stmt) */ exprPair pair; @@ -307,7 +307,7 @@ extern exprNode exprNode_statement (/*@only@*/ exprNode p_e, /*@only@*/ lltok p_ 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 diff --git a/src/Headers/fileTable.h b/src/Headers/fileTable.h index 313f92d..33c0d2f 100644 --- a/src/Headers/fileTable.h +++ b/src/Headers/fileTable.h @@ -68,6 +68,11 @@ extern /*@observer@*/ cstring fileTable_getName (fileTable p_ft, fileId p_fid) / 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) @@ -112,7 +117,7 @@ extern bool fileId_isHeader (fileId p_f) /*@*/ ; 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); diff --git a/src/Headers/filelocStack.h b/src/Headers/filelocStack.h index 278b47c..6014053 100644 --- a/src/Headers/filelocStack.h +++ b/src/Headers/filelocStack.h @@ -22,7 +22,7 @@ extern int filelocStack_size (/*@sef@*/ filelocStack p_s) /*@*/ ; # 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@*/ ; diff --git a/src/Headers/flagMarkerList.h b/src/Headers/flagMarkerList.h index 86665de..8828ff0 100644 --- a/src/Headers/flagMarkerList.h +++ b/src/Headers/flagMarkerList.h @@ -32,7 +32,7 @@ extern ynm 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) /*@*/ ; diff --git a/src/Headers/flag_codes.h b/src/Headers/flag_codes.h index 11784d5..cf5a8a7 100644 --- a/src/Headers/flag_codes.h +++ b/src/Headers/flag_codes.h @@ -29,7 +29,7 @@ typedef enum # define NUMVALUEFLAGS 14 /*@constant int NUMSTRINGFLAGS; @*/ -# define NUMSTRINGFLAGS 24 +# define NUMSTRINGFLAGS 27 /*@iter allFlagCodes (yield flagcode f); @*/ # define allFlagCodes(m_code) \ diff --git a/src/Headers/flags.h b/src/Headers/flags.h index d81d95a..8bb783e 100644 --- a/src/Headers/flags.h +++ b/src/Headers/flags.h @@ -39,7 +39,7 @@ extern bool flagcode_isNamePrefixFlag (flagcode p_f); 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); @@ -55,7 +55,7 @@ extern bool flagcode_equal (flagcode p_code1, flagcode p_code2) /*@*/ ; 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) @@ -80,26 +80,27 @@ extern bool flagcode_isWarnUseFlag (/*@sef@*/ flagcode p_f); # 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 diff --git a/src/Headers/globals.h b/src/Headers/globals.h index aafb222..75e70c5 100644 --- a/src/Headers/globals.h +++ b/src/Headers/globals.h @@ -8,8 +8,18 @@ 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. */ diff --git a/src/Headers/llerror.h b/src/Headers/llerror.h index ad37b96..e54c01d 100644 --- a/src/Headers/llerror.h +++ b/src/Headers/llerror.h @@ -67,31 +67,32 @@ extern /*@noreturnwhenfalse@*/ void llassertfatal (/*@sef@*/ bool p_test); ** 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) @@ -99,33 +100,38 @@ extern /*@private@*/ bool 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); @@ -142,30 +148,42 @@ extern bool lclHadError (void); 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. @@ -174,11 +192,11 @@ extern void cleanupMessages (void) 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)) @@ -189,28 +207,28 @@ optgenerror2 (flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_lo 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)) @@ -219,12 +237,12 @@ extern /*@private@*/ bool 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) @@ -233,13 +251,13 @@ extern bool xllgentypeerror (char *p_srcFile, int p_srcLine, 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) @@ -249,7 +267,7 @@ extern bool gentypeerror (/*@sef@*/ ctype p_t1, /*@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) \ @@ -266,7 +284,7 @@ extern bool gentypeerror (/*@sef@*/ ctype p_t1, 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) \ @@ -277,23 +295,23 @@ extern bool 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)) /* @@ -337,26 +355,27 @@ extern void 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))) @@ -373,6 +392,7 @@ extern void llmsglit (char *p_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); @@ -383,8 +403,16 @@ extern void llgenindentmsgnoloc (/*@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@*/ ; diff --git a/src/Headers/llgrammar.h b/src/Headers/llgrammar.h index b8da786..002cb6f 100644 --- a/src/Headers/llgrammar.h +++ b/src/Headers/llgrammar.h @@ -4,7 +4,7 @@ # 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 diff --git a/src/Headers/llmain.h b/src/Headers/llmain.h index 89b89d0..89ca3dc 100644 --- a/src/Headers/llmain.h +++ b/src/Headers/llmain.h @@ -10,7 +10,7 @@ extern int main (int p_argc, char *p_argv[]) # ifdef NOLCL /*@globals killed undef g_currentloc, killed undef yyin, - undef g_msgstream, + undef g_warningstream, @*/ /*@modifies g_currentloc, fileSystem, internalState, yyin; @*/ @@ -21,7 +21,7 @@ extern int main (int p_argc, char *p_argv[]) 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, diff --git a/src/Headers/lltok.h b/src/Headers/lltok.h index 33c2683..3b0ceca 100644 --- a/src/Headers/lltok.h +++ b/src/Headers/lltok.h @@ -10,24 +10,21 @@ # 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); diff --git a/src/Headers/nameChecks.h b/src/Headers/nameChecks.h index be55699..876adcb 100644 --- a/src/Headers/nameChecks.h +++ b/src/Headers/nameChecks.h @@ -7,13 +7,13 @@ # 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 diff --git a/src/Headers/sRef.h b/src/Headers/sRef.h index 16a6ab3..3b010f9 100644 --- a/src/Headers/sRef.h +++ b/src/Headers/sRef.h @@ -305,7 +305,7 @@ extern /*@exposed@*/ sRef 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@*/ ; @@ -411,7 +411,7 @@ extern ynm sRef_isWriteable (sRef p_s) /*@*/ ; 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@*/ ; @@ -421,10 +421,10 @@ extern void sRef_setKept (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@*/ ; diff --git a/src/Headers/sort.h b/src/Headers/sort.h index 63c52b1..14f7a5c 100644 --- a/src/Headers/sort.h +++ b/src/Headers/sort.h @@ -152,7 +152,7 @@ extern bool sort_setExporting (bool p_flag) /*@modifies internalState@*/ ; # 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@*/ ; diff --git a/src/Headers/stateClauseList.h b/src/Headers/stateClauseList.h index 5049d11..196ee24 100644 --- a/src/Headers/stateClauseList.h +++ b/src/Headers/stateClauseList.h @@ -17,7 +17,7 @@ struct s_stateClauseList } ; 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) @@ -53,7 +53,7 @@ extern int stateClauseList_compare (stateClauseList p_s1, stateClauseList p_s2) # 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) \ diff --git a/src/Headers/transferChecks.h b/src/Headers/transferChecks.h index e797819..3eab5ce 100644 --- a/src/Headers/transferChecks.h +++ b/src/Headers/transferChecks.h @@ -3,11 +3,11 @@ */ 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); diff --git a/src/Headers/uentry.h b/src/Headers/uentry.h index 4b89966..d254919 100644 --- a/src/Headers/uentry.h +++ b/src/Headers/uentry.h @@ -254,7 +254,7 @@ extern void uentry_setMessageLike (uentry p_ue) /*@modifies p_ue@*/ ; 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)) @@ -262,7 +262,7 @@ extern bool uentry_sameObject (uentry p_e1, uentry p_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); @@ -358,12 +358,12 @@ extern /*@notnull@*/ uentry uentry_makeExpandedMacro (cstring p_s, /*@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); @@ -517,15 +517,15 @@ extern void uentry_setStateClauseList (uentry p_ue, /*@only@*/ stateClauseList p 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) /*@*/ ; diff --git a/src/Headers/usymtab-branch.h b/src/Headers/usymtab-branch.h index 9401643..db405bf 100644 --- a/src/Headers/usymtab-branch.h +++ b/src/Headers/usymtab-branch.h @@ -63,7 +63,7 @@ struct _usymtab extern void usymtab_printTypes (void) /*@globals internalState@*/ - /*@modifies g_msgstream@*/ ; + /*@modifies g_warningstream@*/ ; extern void usymtab_setMustBreak (void) /*@modifies internalState@*/ ; @@ -72,15 +72,15 @@ extern bool usymtab_inFunctionScope (void) /*@globals 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@*/ ; @@ -245,15 +245,15 @@ extern typeId typeId_fromInt (int p_i); 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;@*/ ; @@ -314,7 +314,7 @@ extern void 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@*/ ; @@ -422,7 +422,7 @@ extern /*@falsewhennull@*/ bool usymtab_isDefined (usymtab p_u) /*@*/ ; 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@*/ ; diff --git a/src/Headers/usymtab.h b/src/Headers/usymtab.h index 4f41823..c6c6bb8 100644 --- a/src/Headers/usymtab.h +++ b/src/Headers/usymtab.h @@ -47,7 +47,7 @@ struct s_usymtab extern void usymtab_printTypes (void) /*@globals internalState@*/ - /*@modifies g_msgstream@*/ ; + /*@modifies g_warningstream@*/ ; extern void usymtab_setMustBreak (void) /*@modifies internalState@*/ ; @@ -56,15 +56,15 @@ extern bool usymtab_inFunctionScope (void) /*@globals 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@*/ ; @@ -229,15 +229,15 @@ extern typeId typeId_fromInt (int p_i); 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;@*/ ; @@ -298,7 +298,7 @@ extern void 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@*/ ; @@ -402,7 +402,7 @@ extern /*@falsewhennull@*/ bool usymtab_isDefined (usymtab p_u) /*@*/ ; 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@*/ ; diff --git a/src/clabstract.c b/src/clabstract.c index 9c4fe20..10dbd04 100644 --- a/src/clabstract.c +++ b/src/clabstract.c @@ -1255,8 +1255,13 @@ void clabstract_declareType (/*@only@*/ exprNodeList decls, /*@only@*/ warnClaus { 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); @@ -1277,6 +1282,7 @@ void clabstract_declareType (/*@only@*/ exprNodeList decls, /*@only@*/ warnClaus 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; } diff --git a/src/constraint.c b/src/constraint.c index e62b55b..cb87d10 100644 --- a/src/constraint.c +++ b/src/constraint.c @@ -121,14 +121,20 @@ constraint makeConstraintParse3 (constraintExpr l, lltok relOp, constraintExpr r 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); diff --git a/src/constraintExpr.c b/src/constraintExpr.c index 1ea7f54..62d8f03 100644 --- a/src/constraintExpr.c +++ b/src/constraintExpr.c @@ -427,7 +427,6 @@ constraintExpr constraintExpr_makeExprNode (exprNode e) exprNode t, t1, t2; lltok tok; - llassert (e != NULL); data = e->edata; @@ -674,7 +673,7 @@ constraintExpr constraintExpr_parseMakeUnaryOp (lltok op, constraintExpr cexpr) constraintExpr ret; ret = constraintExpr_makeUnaryOpConstraintExpr ( cexpr); - switch (op.tok) + switch (lltok_getTok (op)) { case QMAXSET: ret->data = constraintExprData_unaryExprSetOp (ret->data, MAXSET); @@ -798,14 +797,20 @@ constraintExpr constraintExpr_parseMakeBinaryOp (/*@only@*/ constraintExpr expr1 { 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; } diff --git a/src/constraintGeneration.c b/src/constraintGeneration.c index 6331979..8de2712 100644 --- a/src/constraintGeneration.c +++ b/src/constraintGeneration.c @@ -1265,7 +1265,7 @@ void exprNode_exprTraverse (exprNode e, bool definatelv, bool definaterv, /*@ob 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); @@ -1273,7 +1273,7 @@ void exprNode_exprTraverse (exprNode e, bool definatelv, bool definaterv, /*@ob 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); diff --git a/src/context.c b/src/context.c index d900745..07de91c 100644 --- a/src/context.c +++ b/src/context.c @@ -824,7 +824,7 @@ context_resetAllFlags (void) default: break; } /*@=loopswitchbreak@*/ - + context_setString (code, val); } else @@ -839,6 +839,8 @@ context_resetAllFlags (void) /*@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; @@ -2888,76 +2890,133 @@ context_setString (flagcode flag, cstring val) 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; } @@ -3798,15 +3857,6 @@ context_setFlagAux (flagcode f, bool b, bool inFile, { 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. */ @@ -3868,6 +3918,24 @@ context_setFlagAux (flagcode f, bool b, bool inFile, 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); @@ -4785,7 +4853,6 @@ valueTable context_createGlobalMarkerValueTable (stateInfo sinfo) } - /*drl 12/30/01 these are some ugly functions that were added to facilitate struct annotations */ @@ -4877,74 +4944,3 @@ bool hasInvariants (ctype ct) /*@*/ return FALSE; } - -/*drl 1/6/2001: I didn't think these functions were solid enough to include in the - stable release of splint. I coomented them out so that they won't break anything - but didn't delete them because they will be fixed and included later -*/ - -/* -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; -} - -*/ diff --git a/src/cpperror.c b/src/cpperror.c index cd797ed..73a26d9 100644 --- a/src/cpperror.c +++ b/src/cpperror.c @@ -88,7 +88,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # 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); @@ -128,19 +129,19 @@ void cppReader_printContainingFiles (cppReader *pfile) 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); @@ -148,53 +149,19 @@ void cppReader_printContainingFiles (cppReader *pfile) 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 (""), - (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 (""), - (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 */ @@ -263,8 +230,7 @@ cppReader_getLoc (cppReader *pfile) fid = fileTable_addFile (context_fileTable (), fname); } - cppBuffer_lineAndColumn (ip, &line, &col); - + cppBuffer_getLineAndColumn (ip, &line, &col); return fileloc_create (fid, line, col); } else @@ -273,25 +239,6 @@ cppReader_getLoc (cppReader *pfile) } } -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) { @@ -301,11 +248,10 @@ 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. */ @@ -321,12 +267,8 @@ cppReader_warning (cppReader *pfile, /*@only@*/ cstring msg) { 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. */ @@ -351,44 +293,28 @@ cppReader_pedwarn (cppReader *pfile, /*@only@*/ cstring msg) } 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 @@ -407,9 +333,10 @@ cppReader_pedwarnWithLine (cppReader *pfile, int line, int column, 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); } diff --git a/src/cppexp.c b/src/cppexp.c index a41277e..fa4acd2 100644 --- a/src/cppexp.c +++ b/src/cppexp.c @@ -551,20 +551,20 @@ struct operation cppexp_lex (cppReader *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 { @@ -638,7 +638,9 @@ struct operation cppexp_lex (cppReader *pfile) 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; @@ -997,7 +999,7 @@ cppReader_parseExpression (cppReader *pfile) 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; @@ -1018,14 +1020,14 @@ cppReader_parseExpression (cppReader *pfile) && ((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);*/ @@ -1097,7 +1099,7 @@ cppReader_parseExpression (cppReader *pfile) 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; @@ -1116,7 +1118,7 @@ cppReader_parseExpression (cppReader *pfile) 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; @@ -1141,7 +1143,7 @@ cppReader_parseExpression (cppReader *pfile) if ((top->flags & HAVE_VALUE) != 0) { cppReader_errorLit (pfile, - cstring_makeLiteralTemp ("syntax error")); + cstring_makeLiteralTemp ("syntax error")); goto syntax_error; } top->value = ~ v2; @@ -1218,13 +1220,13 @@ cppReader_parseExpression (cppReader *pfile) /*@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) @@ -1232,7 +1234,7 @@ cppReader_parseExpression (cppReader *pfile) || ((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 @@ -1254,7 +1256,7 @@ cppReader_parseExpression (cppReader *pfile) || ((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 @@ -1282,7 +1284,7 @@ cppReader_parseExpression (cppReader *pfile) if (top != stack) { cppReader_errorLit (pfile, - cstring_makeLiteralTemp ("internal error in #if expression")); + cstring_makeLiteralTemp ("internal error in #if expression")); } val = top->value; diff --git a/src/cpplib.c b/src/cpplib.c index 302167c..25e1271 100644 --- a/src/cpplib.c +++ b/src/cpplib.c @@ -145,7 +145,7 @@ static void cpp_setLocation (cppReader *p_pfile) 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@*/ ; @@ -2173,7 +2173,7 @@ create_definition (/*@exposed@*/ char *buf, char *limit, DPRINTF (("Create definition: %s", buf)); *limit = save; - cppBuffer_lineAndColumn (CPPBUFFER (pfile), &line, &col); + cppBuffer_getLineAndColumn (CPPBUFFER (pfile), &line, &col); bp = buf; @@ -3080,7 +3080,7 @@ update_position (cppBuffer *pbuf) } void -cppBuffer_lineAndColumn (/*@null@*/ cppBuffer *pbuf, /*@out@*/ int *linep, +cppBuffer_getLineAndColumn (/*@null@*/ cppBuffer *pbuf, /*@out@*/ int *linep, /*@null@*/ /*@out@*/ int *colp) { int dummy; @@ -3899,7 +3899,7 @@ cpplib_macroExpand (cppReader *pfile, /*@dependent@*/ hashNode hp) 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; @@ -4039,7 +4039,7 @@ cpplib_macroExpand (cppReader *pfile, /*@dependent@*/ hashNode hp) ** 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. @@ -5994,7 +5994,7 @@ get_next: } newlines = 0; - cppBuffer_lineAndColumn (cppReader_fileBuffer (pfile), + cppBuffer_getLineAndColumn (cppReader_fileBuffer (pfile), &start_line, &start_column); c = skip_comment (pfile, &newlines); @@ -6055,8 +6055,8 @@ get_next: 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); diff --git a/src/cscanner.l b/src/cscanner.l index 7e1e445..3e962cf 100644 --- a/src/cscanner.l +++ b/src/cscanner.l @@ -476,7 +476,7 @@ L'(\\.|[^\\'])+' { setTokLengthT (mstring_length (yytext)); 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); } diff --git a/src/cttable.i b/src/cttable.i index dc1fcff..18a30eb 100644 --- a/src/cttable.i +++ b/src/cttable.i @@ -286,19 +286,19 @@ cttable_print (void) { 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: \n", i); */ + /* fprintf (g_warningstream, "%3d: \n", i); */ } } /*@noaccess ctbase@*/ @@ -319,17 +319,12 @@ cttable_dump (FILE *fout) 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; @@ -342,7 +337,7 @@ cttable_dump (FILE *fout) if (showdots && (i != 0 && ((i - 1) % showdotstride == 0))) { - (void) fflush (g_msgstream); + (void) fflush (g_warningstream); fprintf (stderr, "."); (void) fflush (stderr); } diff --git a/src/exprData.c b/src/exprData.c index c7be031..2c18d5f 100644 --- a/src/exprData.c +++ b/src/exprData.c @@ -460,7 +460,7 @@ void exprData_free (/*@only@*/ exprData data, exprKind kind) /*@observer@*/ lltok exprData_getTok (exprData data) /*@*/ { llassert (data != exprData_undefined); - return (*data->tok); + return data->tok; } /*@exposed@*/ qtype exprData_getType (exprData data) /*@*/ @@ -526,9 +526,8 @@ void exprData_free (/*@only@*/ exprData data, exprKind kind) /*@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; } diff --git a/src/exprNode.c b/src/exprNode.c index 6c41838..a6faf5a 100644 --- a/src/exprNode.c +++ b/src/exprNode.c @@ -4131,7 +4131,7 @@ exprNode_fieldAccess (/*@only@*/ exprNode s, /*@only@*/ lltok dot, /*@only@*/ cstring f) { exprNode res = exprNode_fieldAccessAux (s, lltok_getLoc (dot), f); - lltok_release (dot); + lltok_free (dot); return res; } @@ -4335,7 +4335,7 @@ exprNode_arrowAccess (/*@only@*/ exprNode s, /*@only@*/ cstring f) { exprNode res = exprNode_arrowAccessAux (s, lltok_getLoc (arrow), f); - lltok_release (arrow); + lltok_free (arrow); return res; } @@ -4974,7 +4974,7 @@ exprNode_cast (/*@only@*/ lltok tok, /*@only@*/ exprNode e, /*@only@*/ qtype q) if (exprNode_isError (e)) { qtype_free (q); - lltok_release (tok); + lltok_free (tok); return exprNode_undefined; } diff --git a/src/fileTable.c b/src/fileTable.c index 7869f87..f33835a 100644 --- a/src/fileTable.c +++ b/src/fileTable.c @@ -56,6 +56,10 @@ /*@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)); @@ -372,6 +376,12 @@ fileTable_addHeaderFile (fileTable ft, cstring name) } +void +fileTable_addStreamFile (fileTable ft, FILE *fstream, cstring name) +{ + fileTable_addOpen (ft, fstream, cstring_copy (name)); +} + bool fileTable_isHeader (fileTable ft, fileId fid) { @@ -751,7 +761,7 @@ fileTable_cleanup (fileTable ft) if (msg) { - (void) fflush (g_msgstream); + (void) fflush (g_warningstream); fprintf (stderr, "< cleaning"); } @@ -794,7 +804,7 @@ fileTable_cleanup (fileTable ft) if (msg && ((i % skip) == 0)) { - (void) fflush (g_msgstream); + (void) fflush (g_warningstream); if (i == 0) { fprintf (stderr, " "); diff --git a/src/flagSpec.c b/src/flagSpec.c index 6bceb5e..939a07d 100644 --- a/src/flagSpec.c +++ b/src/flagSpec.c @@ -30,7 +30,10 @@ static /*@only@*/ flagSpecItem flagSpecItem_create (/*@only@*/ cstring fname) { - flagSpecItem res = (flagSpecItem) dmalloc (sizeof (*res)); + flagSpecItem res = (flagSpecItem) dmalloc (sizeof (*res)); + DPRINTF (("Creating item: [%p]", fname)); + DPRINTF (("The name is: %s", fname)); + res->name = fname; res->code = flags_identifyFlag (fname); /* Invalid flag okay for now... */ @@ -48,14 +51,16 @@ static /*@only@*/ flagSpec flagSpec_create (/*@only@*/ flagSpecItem fitem, { flagSpec res = (flagSpec) dmalloc (sizeof (*res)); res->tspec = fitem; - res->trest = frest; + res->trest = frest; + 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); + flagSpec res = flagSpec_create (fitem, flagSpec_undefined); + DPRINTF (("New flag spec: %s", flagSpec_unparse (res))); return res; } diff --git a/src/flags.c b/src/flags.c index 8ddf843..389da7e 100644 --- a/src/flags.c +++ b/src/flags.c @@ -190,7 +190,7 @@ static cstring describeFlagCode (flagcode p_flag) /*@*/ ; 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) /*@*/ ; @@ -221,6 +221,28 @@ bool flagcode_isNameChecksFlag (flagcode f) 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. */ @@ -1180,6 +1202,23 @@ flags_identifyFlagAux (cstring s, bool quiet) 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 , " + "warning-stream-stdout, warning-stream-stderr, warning-stream , " + "error-stream-stdout, error-stream-stderr, error-stream .")); + } + + res = SKIP_FLAG; + } + else if (cstring_equalLit (cflag, "stdio")) { if (!quiet) diff --git a/src/flags.def b/src/flags.def index b230b3a..1bba23b 100644 --- a/src/flags.def +++ b/src/flags.def @@ -3532,7 +3532,8 @@ static flaglist flags = FK_SYNTAX, FK_PREPROC, plainFlag, "preproc", FLG_PREPROC, - "preprocessing error", NULL, + "preprocessing error", + "Preprocessing error.", 0, 0 }, @@ -4082,13 +4083,86 @@ static flaglist flags = "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 ", + 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 ", + 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 ", + 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", diff --git a/src/globals.c b/src/globals.c index 4eb1928..515592d 100644 --- a/src/globals.c +++ b/src/globals.c @@ -40,7 +40,14 @@ int g_codeLine = 0; 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... diff --git a/src/globalsClause.c b/src/globalsClause.c index e9508d1..c32465e 100644 --- a/src/globalsClause.c +++ b/src/globalsClause.c @@ -33,7 +33,7 @@ globalsClause_create (lltok tok, globSet gl) { 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... */ } diff --git a/src/lclinit.c b/src/lclinit.c index aeb0641..58a1260 100644 --- a/src/lclinit.c +++ b/src/lclinit.c @@ -107,7 +107,7 @@ static void ProcessSynonym (void) /*@modifies nextToken@*/ ; 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]; diff --git a/src/lcllib.c b/src/lcllib.c index a9e1900..cc7d661 100644 --- a/src/lcllib.c +++ b/src/lcllib.c @@ -265,12 +265,7 @@ lcllib_isSkipHeader (cstring sname) static void printDot (void) { - if (context_getFlag (FLG_SHOWSCAN)) - { - (void) fflush (g_msgstream); - fprintf (stderr, "."); - (void) fflush (stderr); - } + displayScanContinue (cstring_makeLiteralTemp (".")); } void @@ -281,10 +276,7 @@ dumpState (cstring cfname) 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) { @@ -338,11 +330,7 @@ dumpState (cstring cfname) check (fileTable_closeFile (context_fileTable (), f)); } - if (context_getFlag (FLG_SHOWSCAN)) - { - fprintf (g_msgstream, " >\n"); - } - + displayScanClose (); cstring_free (fname); } @@ -427,17 +415,9 @@ loadStandardState () 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)); } @@ -593,9 +573,7 @@ loadState (cstring cfname) if (f == NULL) { - if (context_getDebug (FLG_SHOWSCAN)) - fprintf (g_msgstream, " >\n"); - + displayScanClose (); llfatalerror (message ("Cannot open dump file for loading: %s", fname)); } diff --git a/src/llerror.c b/src/llerror.c index 3221841..e7dfe9f 100644 --- a/src/llerror.c +++ b/src/llerror.c @@ -54,10 +54,10 @@ static /*@only@*/ fileloc lastparseerror = fileloc_undefined; 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 @*/ @@ -65,10 +65,10 @@ static void printError (FILE *p_stream, /*@only@*/ cstring p_sc) 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.", @@ -87,7 +87,7 @@ maxcp (/*@null@*/ /*@returned@*/ char *a, /*@null@*/ /*@returned@*/ char *b) 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); */ @@ -95,17 +95,17 @@ printBugReport (void) 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; } @@ -115,11 +115,10 @@ void prepareMessage (void) 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; } @@ -134,7 +133,7 @@ llmsg (/*@only@*/ cstring s) { context_setNeednl (); prepareMessage (); - printMessage (g_msgstream, s); + printMessage (g_messagestream, s); closeMessage (); } @@ -145,7 +144,9 @@ lldiagmsg (/*@only@*/ cstring s) 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); } @@ -153,7 +154,7 @@ lldiagmsg (/*@only@*/ cstring s) context_setNeednl (); prepareMessage (); - printMessage (stderr, s); + printMessage (g_messagestream, s); closeMessage (); inmsg = FALSE; @@ -164,7 +165,7 @@ llmsgplain (/*@only@*/ cstring s) { context_setNeednl (); prepareMessage (); - printMessage (g_msgstream, s); + printMessage (g_messagestream, s); closeMessage (); } @@ -190,14 +191,14 @@ void llerror_flagWarning (cstring s) } 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 @@ -336,7 +337,7 @@ llnosuppresshint (flagcode f) if (cstring_isDefined (desc)) { - printError (g_msgstream, message (" %s", desc)); + printError (g_warningstream, message (" %s", desc)); } } } @@ -561,7 +562,7 @@ void cleanupMessages () if (unprinted == 1 && cstring_isDefined (saveOneMessage)) { prepareMessage (); - printError (g_msgstream, saveOneMessage); + printError (g_warningstream, saveOneMessage); closeMessage (); saveOneMessage = cstring_undefined; } @@ -573,7 +574,7 @@ void cleanupMessages () 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 ()); } @@ -590,7 +591,7 @@ llgenmsg (/*@only@*/ cstring s, fileloc fl) lastfileloclen = cstring_length (flstring); prepareMessage (); - (void) printError (g_msgstream, message ("%q: %q", flstring, s)); + (void) printError (g_warningstream, message ("%q: %q", flstring, s)); closeMessage (); } @@ -600,7 +601,7 @@ llgenindentmsg (/*@only@*/ cstring s, fileloc fl) 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 (); } @@ -608,7 +609,7 @@ void llgenindentmsgnoloc (/*@only@*/ cstring s) { prepareMessage (); - (void) printIndentMessage (g_msgstream, s, context_getIndentSpaces ()); + (void) printIndentMessage (g_warningstream, s, context_getIndentSpaces ()); closeMessage (); } @@ -1108,24 +1109,24 @@ llgenerrorreal (char *srcFile, int srcLine, 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 ())); } @@ -1139,11 +1140,11 @@ llgenerrorreal (char *srcFile, int srcLine, 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); @@ -1331,8 +1332,8 @@ void 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 (); @@ -1344,7 +1345,7 @@ void lclfatalbug (char *msg) { prepareMessage (); - printError (stderr, + printError (g_errorstream, message ("*** Fatal Bug: %s", cstring_fromChars (msg))); printCodePoint (); printBugReport (); @@ -1372,7 +1373,8 @@ void llbugaux (cstring file, int line, /*@only@*/ cstring s) { 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); @@ -1384,58 +1386,46 @@ void llbugaux (cstring file, int line, /*@only@*/ cstring s) 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 .)", - fileloc_unparse (g_currentloc))); + llfatalerror + (message ("%q: Cannot recover from last bug. " + "(If you really want Splint to try to continue, use -bugslimit .)", + 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; } @@ -1444,10 +1434,10 @@ void lclbug (/*@only@*/ cstring s) { prepareMessage (); - printError (stderr, message ("*** Internal Bug: %q", s)); + printError (g_errorstream, message ("*** Internal Bug: %q", s)); printCodePoint (); printBugReport (); - fprintf (stderr, " (attempting to continue, results may be incorrect)\n"); + fprintf (g_errorstream, " (attempting to continue, results may be incorrect)\n"); closeMessage (); } # endif @@ -1456,8 +1446,8 @@ void 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); } @@ -1465,10 +1455,10 @@ void 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); } @@ -1509,15 +1499,14 @@ xlclerror (char *srcFile, int srcLine, ltoken t, /*@only@*/ cstring msg) 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); } } @@ -1526,24 +1515,32 @@ void 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); } @@ -1579,9 +1576,9 @@ void genppllerror (flagcode code, /*@only@*/ cstring s) { if (context_getFlag (code)) { - if (context_getFlag (FLG_SHOWSCAN) && !context_isInCommandLine ()) + if (!context_isInCommandLine ()) { - fprintf (g_msgstream, " >\n"); + displayScanClose (); } llerror (code, s); @@ -1591,9 +1588,9 @@ void genppllerror (flagcode code, /*@only@*/ cstring s) llsuppresshint ('-', code); } - if (context_getFlag (FLG_SHOWSCAN) && !context_isInCommandLine ()) + if (!context_isInCommandLine ()) { - fprintf (stderr, "< more preprocessing ."); + displayScanOpen (cstring_makeLiteral ("< more preprocessing .")); } } else @@ -1637,11 +1634,11 @@ void ppllerror (/*@only@*/ cstring s) 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 { @@ -1651,16 +1648,9 @@ void pplldiagmsg (cstring s) 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) @@ -1929,10 +1919,10 @@ void llquietbugaux (cstring s, /*@unused@*/ cstring file, /*@unused@*/ int line) # 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 @@ -1943,6 +1933,60 @@ void llquietbugaux (cstring s, /*@unused@*/ cstring file, /*@unused@*/ int line) 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; } + + diff --git a/src/llgrammar.c.der b/src/llgrammar.c.der index 01338b6..773c237 100644 --- a/src/llgrammar.c.der +++ b/src/llgrammar.c.der @@ -213,7 +213,7 @@ static /*@unused@*/ void yyprint (); /*@=noparams@*/ /*@-redecl@*/ -void ylerror (char *) /*@modifies *g_msgstream@*/ ; +void ylerror (char *) /*@modifies *g_warningstream@*/ ; /*@=redecl@*/ bool g_inTypeDef = FALSE; diff --git a/src/llgrammar.y b/src/llgrammar.y index b61d9ff..24039b0 100644 --- a/src/llgrammar.y +++ b/src/llgrammar.y @@ -39,7 +39,7 @@ static /*@unused@*/ void yyprint (); /*@=noparams@*/ /*@-redecl@*/ -void ylerror (char *) /*@modifies *g_msgstream@*/ ; +void ylerror (char *) /*@modifies *g_warningstream@*/ ; /*@=redecl@*/ bool g_inTypeDef = FALSE; diff --git a/src/llmain.c b/src/llmain.c index b6adf98..2031c6d 100644 --- a/src/llmain.c +++ b/src/llmain.c @@ -366,10 +366,7 @@ lslProcess (fileIdList lclfiles) 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 */ @@ -525,11 +522,13 @@ static void handlePassThroughFlag (char *arg) 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 (); } @@ -630,7 +629,7 @@ int main (int argc, char *argv[]) # 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; @@ -642,7 +641,7 @@ int main (int argc, char *argv[]) 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, @@ -667,7 +666,9 @@ int main (int argc, char *argv[]) _wildcard (&argc, &argv); # endif - g_msgstream = stdout; + g_warningstream = stdout; + g_messagestream = stderr; + g_errorstream = stderr; (void) signal (SIGINT, interrupt); (void) signal (SIGSEGV, interrupt); @@ -686,7 +687,7 @@ int main (int argc, char *argv[]) setCodePoint (); g_currentloc = fileloc_createBuiltin (); - + before = clock (); context_initMod (); @@ -800,13 +801,31 @@ int main (int argc, char *argv[]) { 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) { @@ -1010,10 +1029,16 @@ int main (int argc, char *argv[]) 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)) { @@ -1227,7 +1252,7 @@ int main (int argc, char *argv[]) { showHelp (); } - fprintf (g_msgstream, "\n"); + fprintf (g_warningstream, "\n"); fileIdList_free (cfiles); fileIdList_free (xfiles); @@ -1251,17 +1276,9 @@ int main (int argc, char *argv[]) { 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 ())) { @@ -1293,12 +1310,7 @@ int main (int argc, char *argv[]) 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; @@ -1347,10 +1359,7 @@ int main (int argc, char *argv[]) llflush (); - if (context_getFlag (FLG_SHOWSCAN)) - { - fprintf (stderr, "< preprocessing"); - } + displayScanOpen (cstring_makeLiteral ("preprocessing")); lcltime = clock (); @@ -1365,11 +1374,7 @@ int main (int argc, char *argv[]) fileIdList_free (cfiles); - if (context_getFlag (FLG_SHOWSCAN)) - { - fprintf (stderr, " >\n"); - } - + displayScanClose (); pptime = clock (); } else @@ -1421,10 +1426,7 @@ int main (int argc, char *argv[]) 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, @@ -1461,10 +1463,7 @@ int main (int argc, char *argv[]) ** is this correct behaviour? */ - if (context_getFlag (FLG_SHOWSCAN)) - { - lldiagmsg (cstring_makeLiteral ("< global checks >")); - } + displayScan (cstring_makeLiteral ("global checks")); cleanupMessages (); @@ -1532,7 +1531,7 @@ int main (int argc, char *argv[]) expsuccess = TRUE; if (context_neednl ()) - fprintf (g_msgstream, "\n"); + fprintf (g_warningstream, "\n"); # ifndef NOLCL if (nspecErrors > 0) @@ -1665,15 +1664,15 @@ int main (int argc, char *argv[]) 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 @@ -2172,7 +2171,7 @@ interrupt (int i) switch (i) { case SIGINT: - fprintf (stderr, "*** Interrupt\n"); + fprintf (g_errorstream, "*** Interrupt\n"); llexit (LLINTERRUPT); case SIGSEGV: { @@ -2181,28 +2180,28 @@ interrupt (int i) /* 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); } } @@ -2227,7 +2226,7 @@ cleanupFiles (void) 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 @@ -2304,11 +2303,8 @@ bool readOptionsFile (cstring fname, cstringSList *passThroughArgs, bool report) 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); @@ -2686,13 +2682,13 @@ static fileIdList preprocessFiles (fileIdList fl, bool xhfiles) 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++; } diff --git a/src/lltok.c b/src/lltok.c index c886600..4906dc5 100644 --- a/src/lltok.c +++ b/src/lltok.c @@ -34,67 +34,67 @@ 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 */ @@ -103,12 +103,12 @@ bool lltok_isLe_Op (lltok tok) /*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 */ @@ -116,7 +116,7 @@ bool lltok_isMinus_Op (lltok tok) bool lltok_isAmpersand_Op (lltok tok) { - return (tok.tok == TAMPERSAND); + return (tok->tok == TAMPERSAND); } /*end drl added */ @@ -125,24 +125,24 @@ bool lltok_isAmpersand_Op (lltok tok) 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 @@ -150,7 +150,7 @@ lltok_unparse (lltok tok) { char *lit; - switch (tok.tok) + switch (tok->tok) { case BREAK: lit = "break"; break; case CASE: lit = "case"; break; @@ -204,7 +204,7 @@ lltok_unparse (lltok tok) 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; @@ -257,22 +257,17 @@ lltok_unparse (lltok tok) 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; -} diff --git a/src/lslinit.c b/src/lslinit.c index f3be846..01fbdad 100644 --- a/src/lslinit.c +++ b/src/lslinit.c @@ -48,7 +48,7 @@ #endif static void LocalUserError (ltoken p_t, /*@temp@*/ char *p_msg) - /*@modifies *g_msgstream@*/; + /*@modifies *g_warningstream@*/; static /*@only@*/ ltoken nextToken; diff --git a/src/macrocache.c b/src/macrocache.c index 8f44708..6a59b64 100644 --- a/src/macrocache.c +++ b/src/macrocache.c @@ -353,13 +353,10 @@ extern void macrocache_processUndefinedElements (macrocache m) } 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; diff --git a/src/modifiesClause.c b/src/modifiesClause.c index b4ee459..12e15d5 100644 --- a/src/modifiesClause.c +++ b/src/modifiesClause.c @@ -37,7 +37,7 @@ modifiesClause_createNoMods (lltok tok) res->srs = sRefSet_undefined; res->loc = fileloc_copy (lltok_getLoc (tok)); - lltok_release (tok); + lltok_free (tok); return res; } @@ -51,7 +51,7 @@ modifiesClause_create (lltok tok, sRefSet rfs) res->srs = rfs; res->loc = fileloc_copy (lltok_getLoc (tok)); - lltok_release (tok); + lltok_free (tok); return res; } diff --git a/src/mtreader.c b/src/mtreader.c index 05568d4..cd27617 100644 --- a/src/mtreader.c +++ b/src/mtreader.c @@ -71,11 +71,7 @@ void mtreader_readFile (cstring infile) } 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 (); diff --git a/src/nameChecks.c b/src/nameChecks.c index 5cbea67..cce86e6 100644 --- a/src/nameChecks.c +++ b/src/nameChecks.c @@ -30,10 +30,10 @@ # 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) { diff --git a/src/typeIdSet.c b/src/typeIdSet.c index 6df70c6..473bd97 100644 --- a/src/typeIdSet.c +++ b/src/typeIdSet.c @@ -95,7 +95,7 @@ static /*@unused@*/ void tistable_printOut (void) { 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); } } diff --git a/src/uentry.c b/src/uentry.c index 675df28..dd3f587 100644 --- a/src/uentry.c +++ b/src/uentry.c @@ -43,7 +43,7 @@ static bool uentry_isReallySpecified (uentry p_e) /*@*/ ; 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@*/ ; @@ -86,7 +86,7 @@ static void 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, diff --git a/src/usymtab.c b/src/usymtab.c index b5a8f98..ff1af07 100644 --- a/src/usymtab.c +++ b/src/usymtab.c @@ -148,7 +148,7 @@ static /*@exposed@*/ /*@dependent@*/ uentry 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 @@ -2068,8 +2068,8 @@ usymtab_enterFile () { 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 ; @@ -5748,7 +5748,7 @@ usymtab_printOut (void) 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) { @@ -5759,7 +5759,7 @@ usymtab_printOut (void) 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); @@ -5767,17 +5767,17 @@ usymtab_printOut (void) 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); } @@ -5787,7 +5787,7 @@ usymtab_printOut (void) depth++; s = s->env; } - fprintf (g_msgstream, "<<< end usymtab >>>\n"); + fprintf (g_warningstream, "<<< end usymtab >>>\n"); mstring_free (ind); return; } @@ -5808,7 +5808,7 @@ usymtab_printAll (void) static void usymtab_printAllAux (usymtab s) - /*@modifies g_msgstream@*/ + /*@modifies g_warningstream@*/ { int i; int depth = 0; @@ -5984,7 +5984,7 @@ usymtab_printLocal (void) 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); @@ -6145,7 +6145,7 @@ static bool checkDistinctExternalName (uentry e) static bool checkDistinctInternalName (uentry e) /*@globals utab@*/ - /*@modifies *g_msgstream@*/ + /*@modifies *g_warningstream@*/ { usymtab ttab = utab; cstring name = uentry_rawName (e); diff --git a/src/warnClause.c b/src/warnClause.c index ae6d2ba..1577a14 100644 --- a/src/warnClause.c +++ b/src/warnClause.c @@ -38,14 +38,24 @@ static warnClause warnClause_createAux (/*@only@*/ fileloc loc, 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; } diff --git a/test/ansireserved.expect b/test/ansireserved.expect index cb9a30b..109d39d 100644 --- a/test/ansireserved.expect +++ b/test/ansireserved.expect @@ -54,11 +54,11 @@ ansireserved.c:9: Name EVANS is reserved for future library extensions. Macros (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 diff --git a/test/tests2.2.expect b/test/tests2.2.expect index 8a9a00f..1b4ef0f 100644 --- a/test/tests2.2.expect +++ b/test/tests2.2.expect @@ -27,7 +27,7 @@ Finished checking --- 2 code warnings, as expected 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 diff --git a/test/tests2.4.expect b/test/tests2.4.expect index 12b96e5..8ab7e1d 100644 --- a/test/tests2.4.expect +++ b/test/tests2.4.expect @@ -124,4 +124,4 @@ Command Line: Malformed option `-D' 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 diff --git a/test/tests2.4/Makefile b/test/tests2.4/Makefile index 094754b..8984a7b 100644 --- a/test/tests2.4/Makefile +++ b/test/tests2.4/Makefile @@ -76,7 +76,7 @@ alignof: $(SPLINT) alignof.c -expect 2 source: - $(SPLINT) -D DBL_MANT_DIG=25 source.c + $(SPLINT) -D DBL_MANT_DIG=25 source.c -expect 1 -- 2.45.1