diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2017-05-16 00:05:05 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2017-05-16 00:05:05 +0000 |
commit | 588aa9790e9a38ffffcad4041452257b0a4a605c (patch) | |
tree | 989ee123a0612b56e3e1c54dcea11a5404cb71b8 /gcc | |
parent | d73b8f8417ebf6f0bbf64f237fa9db11cfc719f4 (diff) | |
download | gcc-588aa9790e9a38ffffcad4041452257b0a4a605c.zip gcc-588aa9790e9a38ffffcad4041452257b0a4a605c.tar.gz gcc-588aa9790e9a38ffffcad4041452257b0a4a605c.tar.bz2 |
compiler: better error messages for slicing invalid types
Reviewed-on: https://go-review.googlesource.com/43457
From-SVN: r248082
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/go/gofrontend/MERGE | 2 | ||||
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 16 |
2 files changed, 16 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index fec0e79..b1882af 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -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. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index c5e9a0b..97a39f5 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -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); } } |