Fix bug with multiple directives in the preparser

The preparser should ignore "use strong" if the --strong_mode flag
is not turned on, but this should not stop processing subsequent
directives.

R=rossberg@chromium.org
BUG=
LOG=N

Review URL: https://codereview.chromium.org/1752753002

Cr-Commit-Position: refs/heads/master@{#34392}
This commit is contained in:
nikolaos 2016-03-01 05:57:59 -08:00 committed by Commit bot
parent 0cb8a1b774
commit 86a9ef31c7
2 changed files with 27 additions and 1 deletions

View File

@ -376,7 +376,8 @@ class PreParserStatement {
}
bool IsStringLiteral() {
return code_ == kStringLiteralExpressionStatement;
return code_ == kStringLiteralExpressionStatement
|| IsUseStrictLiteral() || IsUseStrongLiteral();
}
bool IsUseStrictLiteral() {

View File

@ -6029,6 +6029,31 @@ TEST(LanguageModeDirectives) {
}
TEST(MultipleLanguageModeDirectives) {
const char* context_data[][2] = {
{ "'use strict'; 'use strong';", "" },
{ "'use strong'; 'use strict';", "" },
{ "function f() { 'use strict'; 'use strong';", "}" },
{ "function f() { 'use strong'; 'use strict';", "}" },
{ NULL, NULL }
};
const char* strict_error_data[] = {
"var x = 42; delete x",
NULL};
const char* strong_error_data[] = {
"var x = 42",
NULL};
static const ParserFlag strong_mode_flags[] = {kAllowStrongMode};
RunParserSyncTest(context_data, strict_error_data, kError,
strong_mode_flags, arraysize(strong_mode_flags));
RunParserSyncTest(context_data, strong_error_data, kError, NULL, 0,
strong_mode_flags, arraysize(strong_mode_flags));
}
TEST(PropertyNameEvalArguments) {
const char* context_data[][2] = {{"'use strict';", ""},
{"'use strong';", ""},