projects
/
gcc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
46b380a
)
compiler: Reject invalid composite literals.
author
Ian Lance Taylor
<ian@gcc.gnu.org>
Tue, 24 Apr 2012 14:54:17 +0000
(14:54 +0000)
committer
Ian Lance Taylor
<ian@gcc.gnu.org>
Tue, 24 Apr 2012 14:54:17 +0000
(14:54 +0000)
From-SVN: r186766
gcc/go/gofrontend/parse.cc
patch
|
blob
|
history
diff --git
a/gcc/go/gofrontend/parse.cc
b/gcc/go/gofrontend/parse.cc
index 7207db58d0da37c5e7a08688e581510cd2d433f0..7a567a1cd14065c3cd64b7d3ea16297024b66a43 100644
(file)
--- 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());