Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add 'gaggedErrors' to the gagging system

The existing gagging/error handling system doesn't allow errors to be
temporarily ungagged, from a context in which they are gagged. Instead of
restoring the total error count to the state it was in before gagging began,
only the gagged errors should be removed from the error count.
  • Loading branch information...
commit 0a927f258e89f92f280c0e855a93ceb05e34a260 1 parent 569077b
@donc donc authored
View
8 src/dsymbol.c
@@ -558,6 +558,10 @@ void Dsymbol::error(const char *format, ...)
fflush(stdmsg);
//halt();
}
+ else
+ {
+ global.gaggedErrors++;
+ }
global.errors++;
//fatal();
@@ -587,6 +591,10 @@ void Dsymbol::error(Loc loc, const char *format, ...)
fflush(stdmsg);
//halt();
}
+ else
+ {
+ global.gaggedErrors++;
+ }
global.errors++;
View
8 src/lexer.c
@@ -318,6 +318,10 @@ void Lexer::error(const char *format, ...)
if (global.errors >= 20) // moderate blizzard of cascading messages
fatal();
}
+ else
+ {
+ global.gaggedErrors++;
+ }
global.errors++;
}
@@ -341,6 +345,10 @@ void Lexer::error(Loc loc, const char *format, ...)
if (global.errors >= 20) // moderate blizzard of cascading messages
fatal();
}
+ else
+ {
+ global.gaggedErrors++;
+ }
global.errors++;
}
View
22 src/mars.c
@@ -98,6 +98,24 @@ Global::Global()
memset(&params, 0, sizeof(Param));
}
+unsigned Global::startGagging()
+{
+ ++gag;
+ return gaggedErrors;
+}
+
+bool Global::endGagging(unsigned oldGagged)
+{
+ bool anyErrs = (gaggedErrors != oldGagged);
+ --gag;
+ // Restore the original state of gagged errors; set total errors
+ // to be original errors + new ungagged errors.
+ errors -= (gaggedErrors - oldGagged);
+ gaggedErrors = oldGagged;
+ return anyErrs;
+}
+
+
char *Loc::toChars()
{
OutBuffer buf;
@@ -177,6 +195,10 @@ void verror(Loc loc, const char *format, va_list ap)
fflush(stdmsg);
//halt();
}
+ else
+ {
+ global.gaggedErrors++;
+ }
global.errors++;
}
View
15 src/mars.h
@@ -256,9 +256,18 @@ struct Global
const char *version;
Param params;
- unsigned errors; // number of errors reported so far
- unsigned warnings; // number of warnings reported so far
- unsigned gag; // !=0 means gag reporting of errors & warnings
+ unsigned errors; // number of errors reported so far
+ unsigned warnings; // number of warnings reported so far
+ unsigned gag; // !=0 means gag reporting of errors & warnings
+ unsigned gaggedErrors; // number of errors reported while gagged
+
+ // Start gagging. Return the current number of gagged errors
+ unsigned startGagging();
+
+ /* End gagging, restoring the old gagged state.
+ * Return true if errors occured while gagged.
+ */
+ bool endGagging(unsigned oldGagged);
Global();
};
View
3  src/traits.c
@@ -263,7 +263,10 @@ Expression *TraitsExp::semantic(Scope *sc)
e = e->trySemantic(sc);
if (!e)
{ if (global.gag)
+ {
global.errors++;
+ global.gaggedErrors++;
+ }
goto Lfalse;
}
else
Please sign in to comment.
Something went wrong with that request. Please try again.