зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1296814 - Introduce Parser::extraWarning. r=anba
--HG-- extra : rebase_source : a9bee3683754ea661a13a4438d0e79f6b711702b
This commit is contained in:
Родитель
a57eb68e02
Коммит
3867d8ce13
|
@ -599,6 +599,17 @@ Parser<ParseHandler>::qeport(ParseReportKind kind, unsigned errorNumber, ...)
|
|||
return result;
|
||||
}
|
||||
|
||||
template <typename ParseHandler>
|
||||
bool
|
||||
Parser<ParseHandler>::extraWarning(unsigned errorNumber, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
bool result = reportHelper(ParseExtraWarning, false, pos().begin, errorNumber, args);
|
||||
va_end(args);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename ParseHandler>
|
||||
bool
|
||||
Parser<ParseHandler>::strictModeError(unsigned errorNumber, ...)
|
||||
|
@ -3867,7 +3878,7 @@ Parser<ParseHandler>::condition(InHandling inHandling, YieldHandling yieldHandli
|
|||
|
||||
/* Check for (a = b) and warn about possible (a == b) mistype. */
|
||||
if (handler.isUnparenthesizedAssignment(pn)) {
|
||||
if (!qeport(ParseExtraWarning, JSMSG_EQUAL_AS_ASSIGN))
|
||||
if (!extraWarning(JSMSG_EQUAL_AS_ASSIGN))
|
||||
return null();
|
||||
}
|
||||
return pn;
|
||||
|
@ -5247,7 +5258,7 @@ Parser<ParseHandler>::ifStatement(YieldHandling yieldHandling)
|
|||
if (!tokenStream.peekToken(&tt, TokenStream::Operand))
|
||||
return null();
|
||||
if (tt == TOK_SEMI) {
|
||||
if (!qeport(ParseExtraWarning, JSMSG_EMPTY_CONSEQUENT))
|
||||
if (!extraWarning(JSMSG_EMPTY_CONSEQUENT))
|
||||
return null();
|
||||
}
|
||||
|
||||
|
@ -8201,7 +8212,7 @@ Parser<ParseHandler>::comprehensionIf(GeneratorKind comprehensionKind)
|
|||
|
||||
/* Check for (a = b) and warn about possible (a == b) mistype. */
|
||||
if (handler.isUnparenthesizedAssignment(cond)) {
|
||||
if (!qeport(ParseExtraWarning, JSMSG_EQUAL_AS_ASSIGN))
|
||||
if (!extraWarning(JSMSG_EQUAL_AS_ASSIGN))
|
||||
return null();
|
||||
}
|
||||
|
||||
|
|
|
@ -920,6 +920,13 @@ class Parser final : private JS::AutoGCRooter, public StrictModeGetter
|
|||
*/
|
||||
MOZ_MUST_USE bool strictModeError(unsigned errorNumber, ...);
|
||||
|
||||
/*
|
||||
* If extra warnings are enabled, report the given warning at the current
|
||||
* offset.
|
||||
*/
|
||||
MOZ_MUST_USE bool extraWarning(unsigned errorNumber, ...);
|
||||
|
||||
|
||||
Parser(ExclusiveContext* cx, LifoAlloc& alloc, const ReadOnlyCompileOptions& options,
|
||||
const char16_t* chars, size_t length, bool foldConstants, UsedNameTracker& usedNames,
|
||||
Parser<SyntaxParseHandler>* syntaxParser, LazyScript* lazyOuterFunction);
|
||||
|
|
Загрузка…
Ссылка в новой задаче