]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
compiler: check duplicate implicit indexes in slices/arrays
authorIan Lance Taylor <ian@gcc.gnu.org>
Tue, 5 Feb 2019 18:21:07 +0000 (18:21 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Tue, 5 Feb 2019 18:21:07 +0000 (18:21 +0000)
    Fixes golang/go#28186.

    Reviewed-on: https://go-review.googlesource.com/c/160832

From-SVN: r268554

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/expressions.cc

index 3b43b63b5d2a822d56b3dae5bd7ebd5ac94f85e0..3220671ad4216cb8c31454cf9ccdd1467c5bde99 100644 (file)
@@ -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.
index ed3863c31a9b4a0670176375eed57fe2d9539c52..8ffd9eb140ebc007ba8d46144bc3e92d1a149bd6 100644 (file)
@@ -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);
        }