Fix suppression of messages under debug

This commit is contained in:
Wilson Snyder 2010-12-30 08:41:23 -05:00
parent b763809f5e
commit b43299c8da
3 changed files with 16 additions and 16 deletions

View File

@ -859,7 +859,7 @@ private:
AstNode* errorp = simvis.whyNotNodep(); if (!errorp) errorp = nodep;
nodep->v3error("Expecting expression to be constant, but can't determine constant for "
<<nodep->prettyTypeName()<<endl
<<V3Error::msgPrefix(V3ErrorCode::EC_ERROR)<<errorp->fileline()<<"... Location of non-constant "
<<V3Error::msgPrefix(V3ErrorCode::EC_ERROR,false)<<errorp->fileline()<<"... Location of non-constant "
<<errorp->prettyTypeName()<<": "<<simvis.whyNotMessage());
replaceZero(nodep); nodep=NULL;
} else {

View File

@ -42,6 +42,7 @@ int V3Error::s_debugDefault = 0;
int V3Error::s_tellManual = 0;
ostringstream V3Error::s_errorStr; // Error string being formed
V3ErrorCode V3Error::s_errorCode = V3ErrorCode::EC_FATAL;
bool V3Error::s_errorSuppressed = false;
bool V3Error::s_describedEachWarn[V3ErrorCode::_ENUM_MAX];
bool V3Error::s_describedWarnings = false;
bool V3Error::s_pretendError[V3ErrorCode::_ENUM_MAX];
@ -313,8 +314,8 @@ void V3Error::abortIfWarnings() {
}
}
bool V3Error::isError(V3ErrorCode code) {
if (code==V3ErrorCode::EC_SUPPRESS) return false;
bool V3Error::isError(V3ErrorCode code, bool supp) {
if (supp) return false;
else if (code==V3ErrorCode::EC_INFO) return false;
else if (code==V3ErrorCode::EC_FATAL) return true;
else if (code==V3ErrorCode::EC_FATALSRC) return true;
@ -324,13 +325,13 @@ bool V3Error::isError(V3ErrorCode code) {
else return false;
}
string V3Error::msgPrefix(V3ErrorCode code) {
if (code==V3ErrorCode::EC_SUPPRESS) return "-arning-suppressed: ";
string V3Error::msgPrefix(V3ErrorCode code, bool supp) {
if (supp) return "-arning-suppressed: ";
else if (code==V3ErrorCode::EC_INFO) return "-Info: ";
else if (code==V3ErrorCode::EC_FATAL) return "%Error: ";
else if (code==V3ErrorCode::EC_FATALSRC) return "%Error: Internal Error: ";
else if (code==V3ErrorCode::EC_ERROR) return "%Error: ";
else if (isError(code)) return "%Error-"+(string)code.ascii()+": ";
else if (isError(code, supp)) return "%Error-"+(string)code.ascii()+": ";
else return "%Warning-"+(string)code.ascii()+": ";
}
@ -364,7 +365,7 @@ string V3Error::v3sform (const char* format, ...) {
void V3Error::suppressThisWarning() {
if (s_errorCode>=V3ErrorCode::EC_FIRST_WARN) {
V3Stats::addStatSum(string("Warnings, Suppressed ")+s_errorCode.ascii(), 1);
s_errorCode=V3ErrorCode::EC_SUPPRESS;
s_errorSuppressed = true;
}
}
@ -372,15 +373,14 @@ void V3Error::v3errorEnd (ostringstream& sstr) {
#ifdef __COVERITY__
if (s_errorCode==V3ErrorCode::EC_FATAL) __coverity_panic__(x);
#endif
if (s_errorCode!=V3ErrorCode::EC_SUPPRESS
if (!s_errorSuppressed
// On debug, show only non default-off warning to prevent pages of warnings
|| (debug() && !s_errorCode.defaultsOff())) {
cerr<<msgPrefix()<<sstr.str();
if (sstr.str()[sstr.str().length()-1] != '\n') {
cerr<<endl;
}
if (s_errorCode!=V3ErrorCode::EC_SUPPRESS
&& s_errorCode!=V3ErrorCode::EC_INFO) {
if (!s_errorSuppressed && s_errorCode!=V3ErrorCode::EC_INFO) {
if (!s_describedEachWarn[s_errorCode]
&& !s_pretendError[s_errorCode]) {
s_describedEachWarn[s_errorCode] = true;
@ -404,7 +404,7 @@ void V3Error::v3errorEnd (ostringstream& sstr) {
s_tellManual = 2;
}
}
if (isError(s_errorCode)) incErrors();
if (isError(s_errorCode, s_errorSuppressed)) incErrors();
else incWarnings();
if (s_errorCode==V3ErrorCode::EC_FATAL
|| s_errorCode==V3ErrorCode::EC_FATALSRC) {

View File

@ -36,7 +36,6 @@ public:
enum en {
EC_MIN=0, // Keep first
//
EC_SUPPRESS, // Warning suppressed by user
EC_INFO, // General information out
EC_FATAL, // Kill the program
EC_FATALSRC, // Kill the program, for internal source errors
@ -96,7 +95,7 @@ public:
const char* ascii() const {
const char* names[] = {
// Leading spaces indicate it can't be disabled.
" MIN", " SUPPRESS", " INFO", " FATAL", " FATALSRC", " ERROR",
" MIN", " INFO", " FATAL", " FATALSRC", " ERROR",
// Boolean
" I_COVERAGE", " I_TRACING", " I_LINT", " I_DEF_NETTYPE_WIRE",
// Errors
@ -162,6 +161,7 @@ class V3Error {
static int s_tellManual; // Tell user to see manual, 0=not yet, 1=doit, 2=disable
static ostringstream s_errorStr; // Error string being formed
static V3ErrorCode s_errorCode; // Error string being formed will abort
static bool s_errorSuppressed; // Error being formed should be suppressed
enum MaxErrors { MAX_ERRORS = 50 }; // Fatal after this may errors
V3Error() { cerr<<("Static class"); abort(); }
@ -171,7 +171,7 @@ class V3Error {
// ACCESSORS
static void debugDefault(int level) { s_debugDefault = level; }
static int debugDefault() { return s_debugDefault; }
static string msgPrefix(V3ErrorCode code=s_errorCode); // returns %Error/%Warn
static string msgPrefix(V3ErrorCode code=s_errorCode, bool supp=s_errorSuppressed); // returns %Error/%Warn
static int errorCount() { return s_errCount; }
static int warnCount() { return s_warnCount; }
static int errorOrWarnCount() { return errorCount()+warnCount(); }
@ -183,7 +183,7 @@ class V3Error {
static void abortIfWarnings();
static void suppressThisWarning(); // Suppress next %Warn if user has it off
static void pretendError(V3ErrorCode code, bool flag) { s_pretendError[code]=flag; }
static bool isError(V3ErrorCode code);
static bool isError(V3ErrorCode code, bool supp);
static string v3sform (const char* format, ...);
static string lineStr (const char* filename, int lineno);
static V3ErrorCode errorCode() { return s_errorCode; }
@ -191,7 +191,7 @@ class V3Error {
// Internals for v3error()/v3fatal() macros only
// Error end takes the string stream to output, be careful to seek() as needed
static ostringstream& v3errorPrep (V3ErrorCode code) {
s_errorStr.str(""); s_errorCode=code; return s_errorStr; }
s_errorStr.str(""); s_errorCode=code; s_errorSuppressed=false; return s_errorStr; }
static ostringstream& v3errorStr () { return s_errorStr; }
static void vlAbort();
static void v3errorEnd(ostringstream& sstr); // static, but often overridden in classes.