From: Ian Lance Taylor Date: Tue, 5 Feb 2019 18:21:07 +0000 (+0000) Subject: compiler: check duplicate implicit indexes in slices/arrays X-Git-Tag: basepoints/gcc-10~1333 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b81e1cd506ad06e4eb0a658d26119129d110a5a9;p=thirdparty%2Fgcc.git compiler: check duplicate implicit indexes in slices/arrays Fixes golang/go#28186. Reviewed-on: https://go-review.googlesource.com/c/160832 From-SVN: r268554 --- diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 3b43b63b5d2a..3220671ad421 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -047b0aa6a29d46fde99b3e5823339ac8866f797c +347628daf153baf3034b61b2abb4ec39e2ab37c8 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index ed3863c31a9b..8ffd9eb140eb 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -14244,6 +14244,13 @@ Composite_literal_expression::lower_array(Type* type) if (index_expr == NULL) { + if (std::find(indexes->begin(), indexes->end(), index) + != indexes->end()) + { + go_error_at(val->location(), + "duplicate value for index %lu", index); + return Expression::make_error(location); + } if (!indexes->empty()) indexes->push_back(index); }