summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/src/frontend/TokenStream.cpp16
-rw-r--r--js/src/frontend/TokenStream.h8
2 files changed, 14 insertions, 10 deletions
diff --git a/js/src/frontend/TokenStream.cpp b/js/src/frontend/TokenStream.cpp
index 9becaf55e..e8d622d38 100644
--- a/js/src/frontend/TokenStream.cpp
+++ b/js/src/frontend/TokenStream.cpp
@@ -777,7 +777,7 @@ TokenStream::reportErrorNoOffset(unsigned errorNumber, ...)
}
bool
-TokenStream::reportWarning(unsigned errorNumber, ...)
+TokenStream::warning(unsigned errorNumber, ...)
{
va_list args;
va_start(args, errorNumber);
@@ -958,9 +958,10 @@ TokenStream::getDirective(bool isMultiline, bool shouldWarnDeprecated,
int32_t c;
if (peekChars(directiveLength, peeked) && CharsMatch(peeked, directive)) {
- if (shouldWarnDeprecated &&
- !reportWarning(JSMSG_DEPRECATED_PRAGMA, errorMsgPragma))
- return false;
+ if (shouldWarnDeprecated) {
+ if (!warning(JSMSG_DEPRECATED_PRAGMA, errorMsgPragma))
+ return false;
+ }
skipChars(directiveLength);
tokenbuf.clear();
@@ -1555,10 +1556,11 @@ TokenStream::getTokenInternal(TokenKind* ttp, Modifier modifier)
// grammar. We might not always be so permissive, so we warn
// about it.
if (c >= '8') {
- if (!reportWarning(JSMSG_BAD_OCTAL, c == '8' ? "08" : "09")) {
+ if (!warning(JSMSG_BAD_OCTAL, c == '8' ? "08" : "09"))
goto error;
- }
- goto decimal; // use the decimal scanner for the rest of the number
+
+ // Use the decimal scanner for the rest of the number.
+ goto decimal;
}
c = getCharIgnoreEOL();
}
diff --git a/js/src/frontend/TokenStream.h b/js/src/frontend/TokenStream.h
index f08d317ba..18e9cb3ca 100644
--- a/js/src/frontend/TokenStream.h
+++ b/js/src/frontend/TokenStream.h
@@ -364,16 +364,18 @@ class MOZ_STACK_CLASS TokenStream
// TokenStream-specific error reporters.
bool reportError(unsigned errorNumber, ...);
bool reportErrorNoOffset(unsigned errorNumber, ...);
- bool reportWarning(unsigned errorNumber, ...);
// Report the given error at the current offset.
void error(unsigned errorNumber, ...);
+ // Warn at the current offset.
+ MOZ_MUST_USE bool warning(unsigned errorNumber, ...);
+
static const uint32_t NoOffset = UINT32_MAX;
// General-purpose error reporters. You should avoid calling these
- // directly, and instead use the more succinct alternatives (e.g.
- // reportError()) in TokenStream, Parser, and BytecodeEmitter.
+ // directly, and instead use the more succinct alternatives (error(),
+ // warning(), &c.) in TokenStream, Parser, and BytecodeEmitter.
bool reportCompileErrorNumberVA(uint32_t offset, unsigned flags, unsigned errorNumber,
va_list args);
bool reportStrictModeErrorNumberVA(uint32_t offset, bool strictMode, unsigned errorNumber,