Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Unified Diff: src/preparser.cc

Issue 1002253002: [strong] Check super constructor calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Typo Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/preparser.cc
diff --git a/src/preparser.cc b/src/preparser.cc
index e7fff33d3bf7f6d47b96a9debbe5ac7a52c0957f..4111de283fd898a654de31067d37968a66f64215 100644
--- a/src/preparser.cc
+++ b/src/preparser.cc
@@ -194,8 +194,19 @@ void PreParser::ParseStatementList(int end_token, bool* ok) {
if (directive_prologue && peek() != Token::STRING) {
directive_prologue = false;
}
+ Token::Value token = peek();
+ Scanner::Location old_super_loc = function_state_->super_call_location();
Statement statement = ParseStatementListItem(ok);
if (!*ok) return;
+ Scanner::Location super_loc = function_state_->super_call_location();
+ if (is_strong(language_mode()) &&
+ i::IsConstructor(function_state_->kind()) &&
+ !old_super_loc.IsValid() && super_loc.IsValid() &&
+ token != Token::SUPER) {
+ ReportMessageAt(super_loc, "strong_super_call_nested");
+ *ok = false;
+ return;
+ }
if (directive_prologue) {
if (statement.IsUseStrictLiteral()) {
scope_->SetLanguageMode(
@@ -945,6 +956,14 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
CheckStrictOctalLiteral(start_position, end_position, CHECK_OK);
}
+ if (is_strong(language_mode()) && IsSubclassConstructor(kind)) {
+ if (!function_state.super_call_location().IsValid()) {
+ ReportMessageAt(function_name_location, "strong_super_call_missing");
+ *ok = false;
+ return Expression::Default();
+ }
+ }
+
return Expression::Default();
}

Powered by Google App Engine
This is Rietveld 408576698