Commit 0b3998c8 authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

[torque] Fix crash when specialization has wrong argument count

This CL fixes a crash when a macro specialization has the wrong number
of generic arguments. An error message is printed instead.

R=tebbi@chromium.org

Bug: v8:7793
Change-Id: I60a55f0452d4188d94640ccccd3f0271a493cb6e
Reviewed-on: https://chromium-review.googlesource.com/1102318Reviewed-by: 's avatarDaniel Clifford <danno@chromium.org>
Commit-Queue: Simon Zünd <szuend@google.com>
Cr-Commit-Position: refs/heads/master@{#53755}
parent 0190dc8c
......@@ -330,6 +330,16 @@ void DeclarationVisitor::Visit(CallExpression* expr) {
void DeclarationVisitor::DeclareSpecializedTypes(const SpecializationKey& key) {
size_t i = 0;
Generic* generic = key.first;
const std::size_t generic_parameter_count =
generic->declaration()->generic_parameters.size();
if (generic_parameter_count != key.second.size()) {
std::stringstream stream;
stream << "Wrong generic argument count for specialization of \""
<< generic->name() << "\", expected: " << generic_parameter_count
<< ", actual: " << key.second.size();
ReportError(stream.str());
}
for (auto type : key.second) {
std::string generic_type_name =
generic->declaration()->generic_parameters[i++];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment