aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2019-02-05 18:21:07 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-02-05 18:21:07 +0000
commitb81e1cd506ad06e4eb0a658d26119129d110a5a9 (patch)
tree43a2ccdd0380dfc0756ed95ba8085d93a233174d /gcc
parent959dcbc80a60aed2198dab4853a7492b315de7d6 (diff)
downloadgcc-b81e1cd506ad06e4eb0a658d26119129d110a5a9.zip
gcc-b81e1cd506ad06e4eb0a658d26119129d110a5a9.tar.gz
gcc-b81e1cd506ad06e4eb0a658d26119129d110a5a9.tar.bz2
compiler: check duplicate implicit indexes in slices/arrays
Fixes golang/go#28186. Reviewed-on: https://go-review.googlesource.com/c/160832 From-SVN: r268554
Diffstat (limited to 'gcc')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/expressions.cc7
2 files changed, 8 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 3b43b63..3220671 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 ed3863c..8ffd9eb 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);
}