compiler: better error messages for slicing invalid types
authorIan Lance Taylor <ian@gcc.gnu.org>
Tue, 16 May 2017 00:05:05 +0000 (00:05 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Tue, 16 May 2017 00:05:05 +0000 (00:05 +0000)
    Reviewed-on: https://go-review.googlesource.com/43457

From-SVN: r248082

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

index fec0e7978d59279cf1797b36ca57ae0801198579..b1882af5a7f5a8eac6b2da1d3d7c2ee8220f1b81 100644 (file)
@@ -1,4 +1,4 @@
-d3997526dc0710e6b9b727a41184ce1770805794
+924a1fcc5658a5d66f5015921d7258e3a77519bc
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index c5e9a0b6a562eccf07e8c9b403ff90fda206ac6c..97a39f54239e1bcd66d3b4534e630680420df9c0 100644 (file)
@@ -10610,10 +10610,24 @@ Index_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int)
        }
       return Expression::make_map_index(left, start, location);
     }
+  else if (cap != NULL)
+    {
+      go_error_at(location,
+                 "invalid 3-index slice of object that is not a slice");
+      return Expression::make_error(location);
+    }
+  else if (end != NULL)
+    {
+      go_error_at(location,
+                 ("attempt to slice object that is not "
+                  "array, slice, or string"));
+      return Expression::make_error(location);
+    }
   else
     {
       go_error_at(location,
-                  "attempt to index object which is not array, string, or map");
+                  ("attempt to index object that is not "
+                  "array, slice, string, or map"));
       return Expression::make_error(location);
     }
 }