aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/parse.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2016-01-27 18:51:58 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2016-01-27 18:51:58 +0000
commitb45285fc2ee430b675f57e8c92310aaf77ba031e (patch)
tree668ea53d0e4fe91b41cc2d1c49cd4d7983cee20b /gcc/go/gofrontend/parse.cc
parent8f91e6e0eff1494cfefb2129876847aab5748538 (diff)
downloadgcc-b45285fc2ee430b675f57e8c92310aaf77ba031e.zip
gcc-b45285fc2ee430b675f57e8c92310aaf77ba031e.tar.gz
gcc-b45285fc2ee430b675f57e8c92310aaf77ba031e.tar.bz2
compiler: Accept map composite literals with omitted key types.
compiler: Copy key_path_ when copying a Composite_literal_expression. Fixes golang/go#10263. Reviewed-on: https://go-review.googlesource.com/14299 Reviewed-on: https://go-review.googlesource.com/18988 From-SVN: r232892
Diffstat (limited to 'gcc/go/gofrontend/parse.cc')
-rw-r--r--gcc/go/gofrontend/parse.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc
index 5c49370..827eb0a 100644
--- a/gcc/go/gofrontend/parse.cc
+++ b/gcc/go/gofrontend/parse.cc
@@ -2739,7 +2739,7 @@ Parse::composite_lit(Type* type, int depth, Location location)
// This must be a composite literal inside another composite
// literal, with the type omitted for the inner one.
val = this->composite_lit(type, depth + 1, token->location());
- is_type_omitted = true;
+ is_type_omitted = true;
}
token = this->peek_token();
@@ -2751,11 +2751,14 @@ Parse::composite_lit(Type* type, int depth, Location location)
}
else
{
- if (is_type_omitted && !val->is_error_expression())
- {
- error_at(this->location(), "unexpected %<:%>");
- val = Expression::make_error(this->location());
- }
+ if (is_type_omitted)
+ {
+ // VAL is a nested composite literal with an omitted type being
+ // used a key. Record this information in VAL so that the correct
+ // type is associated with the literal value if VAL is a
+ // map literal.
+ val->complit()->update_key_path(depth);
+ }
this->advance_token();