Bug 823310 - Only report strict warnings when JSOPTION_STRICT is set. r=njn,jorendorff
authorBenjamin Peterson <benjamin@python.org>
Fri, 21 Dec 2012 11:02:06 -0600
changeset 125890 5fddad57aa058e49caf46d5e255b24e555b870ec
parent 125889 0134b2193fe5a30b64f16757373d7fed71cb0cae
child 125891 15b8a8271ece82ed8288bfc02db14143998140f5
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn, jorendorff
bugs823310
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 823310 - Only report strict warnings when JSOPTION_STRICT is set. r=njn,jorendorff
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/Parser.h
js/src/frontend/TokenStream.cpp
js/src/frontend/TokenStream.h
js/src/jit-test/tests/basic/bug823310.js
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -1713,17 +1713,17 @@ BytecodeEmitter::reportError(ParseNode *
     return result;
 }
 
 bool
 BytecodeEmitter::reportStrictWarning(ParseNode *pn, unsigned errorNumber, ...)
 {
     va_list args;
     va_start(args, errorNumber);
-    bool result = tokenStream()->reportStrictWarningErrorNumberVA(pn, sc->strict, errorNumber, args);
+    bool result = tokenStream()->reportStrictWarningErrorNumberVA(pn, errorNumber, args);
     va_end(args);
     return result;
 }
 
 bool
 BytecodeEmitter::reportStrictModeError(ParseNode *pn, unsigned errorNumber, ...)
 {
     va_list args;
--- a/js/src/frontend/Parser.h
+++ b/js/src/frontend/Parser.h
@@ -513,18 +513,17 @@ Parser::reportWarning(ParseNode *pn, uns
     return result;
 }
 
 inline bool
 Parser::reportStrictWarning(ParseNode *pn, unsigned errorNumber, ...)
 {
     va_list args;
     va_start(args, errorNumber);
-    bool result = tokenStream.reportStrictWarningErrorNumberVA(pn, pc->sc->strict,
-                                                               errorNumber, args);
+    bool result = tokenStream.reportStrictWarningErrorNumberVA(pn, errorNumber, args);
     va_end(args);
     return result;
 }
 
 inline bool
 Parser::reportStrictModeError(ParseNode *pn, unsigned errorNumber, ...)
 {
     va_list args;
--- a/js/src/frontend/TokenStream.cpp
+++ b/js/src/frontend/TokenStream.cpp
@@ -607,20 +607,19 @@ TokenStream::reportWarning(unsigned erro
     va_list args;
     va_start(args, errorNumber);
     bool result = reportCompileErrorNumberVA(NULL, JSREPORT_WARNING, errorNumber, args);
     va_end(args);
     return result;
 }
 
 bool
-TokenStream::reportStrictWarningErrorNumberVA(ParseNode *pn, bool strictMode, unsigned errorNumber,
-                                              va_list args)
+TokenStream::reportStrictWarningErrorNumberVA(ParseNode *pn, unsigned errorNumber, va_list args)
 {
-    if (!strictMode && !cx->hasStrictOption())
+    if (!cx->hasStrictOption())
         return true;
 
     return reportCompileErrorNumberVA(NULL, JSREPORT_STRICT | JSREPORT_WARNING, errorNumber, args);
 }
 
 #if JS_HAS_XML_SUPPORT
 
 bool
--- a/js/src/frontend/TokenStream.h
+++ b/js/src/frontend/TokenStream.h
@@ -536,18 +536,17 @@ class TokenStream
 
     // 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.
     bool reportCompileErrorNumberVA(ParseNode *pn, unsigned flags, unsigned errorNumber,
                                     va_list args);
     bool reportStrictModeErrorNumberVA(ParseNode *pn, bool strictMode, unsigned errorNumber,
                                        va_list args);
-    bool reportStrictWarningErrorNumberVA(ParseNode *pn, bool strictMode, unsigned errorNumber,
-                                          va_list args);
+    bool reportStrictWarningErrorNumberVA(ParseNode *pn, unsigned errorNumber, va_list args);
 
   private:
     // These are private because they should only be called by the tokenizer
     // while tokenizing not by, for example, BytecodeEmitter.
     bool reportStrictModeError(unsigned errorNumber, ...);
     bool strictMode() const { return strictModeGetter && strictModeGetter->get(); }
 
     void onError();
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/bug823310.js
@@ -0,0 +1,7 @@
+"use strict";
+options("werror");
+
+// This construct causes a strict warning, but we shouldn't get one since
+// JSOPTION_STRICT isn't enabled.
+var x;
+eval("if (x = 3) {}");