diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-04-24 14:54:17 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-04-24 14:54:17 +0000 |
commit | 929eeacd4cb79f4fdea7d79ec7ad14da8e266d10 (patch) | |
tree | 7cf552c36051a19cbecac2981ea3fc7647578dba /gcc/go | |
parent | 46b380a23b6504fe3c5747673e8897debc42a633 (diff) | |
download | gcc-929eeacd4cb79f4fdea7d79ec7ad14da8e266d10.zip gcc-929eeacd4cb79f4fdea7d79ec7ad14da8e266d10.tar.gz gcc-929eeacd4cb79f4fdea7d79ec7ad14da8e266d10.tar.bz2 |
compiler: Reject invalid composite literals.
From-SVN: r186766
Diffstat (limited to 'gcc/go')
-rw-r--r-- | gcc/go/gofrontend/parse.cc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index 7207db5..7a567a1 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -2865,7 +2865,16 @@ Parse::primary_expr(bool may_be_sink, bool may_be_composite_lit, { if (this->peek_token()->is_op(OPERATOR_LCURLY)) { - if (is_parenthesized) + if (!may_be_composite_lit) + { + Type* t = ret->type(); + if (t->named_type() != NULL + || t->forward_declaration_type() != NULL) + error_at(start_loc, + _("parentheses required around this composite literal" + "to avoid parsing ambiguity")); + } + else if (is_parenthesized) error_at(start_loc, "cannot parenthesize type in composite literal"); ret = this->composite_lit(ret->type(), 0, ret->location()); |