diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-10-08 23:54:15 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-10-08 23:54:15 +0000 |
commit | 62750cd5c6a8b9ff364516c86e11bb6d1823e591 (patch) | |
tree | 8a2089703104bb2edffd3b879536df152157fa6d /gcc/go/gofrontend/parse.cc | |
parent | b6d0ea24172ec1b0dc9c16abab856a262edb07d6 (diff) | |
download | gcc-62750cd5c6a8b9ff364516c86e11bb6d1823e591.tar.gz |
compiler: Error for qualified ID as field name in struct literal.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203292 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/go/gofrontend/parse.cc')
-rw-r--r-- | gcc/go/gofrontend/parse.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index e68f1753f87..498125bb241 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -2690,15 +2690,17 @@ Parse::composite_lit(Type* type, int depth, Location location) { this->advance_token(); return Expression::make_composite_literal(type, depth, false, NULL, - location); + false, location); } bool has_keys = false; + bool all_are_names = true; Expression_list* vals = new Expression_list; while (true) { Expression* val; bool is_type_omitted = false; + bool is_name = false; const Token* token = this->peek_token(); @@ -2719,6 +2721,7 @@ Parse::composite_lit(Type* type, int depth, Location location) val = this->id_to_expression(gogo->pack_hidden_name(identifier, is_exported), location); + is_name = true; } else { @@ -2744,6 +2747,7 @@ Parse::composite_lit(Type* type, int depth, Location location) { if (has_keys) vals->push_back(NULL); + is_name = false; } else { @@ -2790,6 +2794,9 @@ Parse::composite_lit(Type* type, int depth, Location location) vals->push_back(val); + if (!is_name) + all_are_names = false; + if (token->is_op(OPERATOR_COMMA)) { if (this->advance_token()->is_op(OPERATOR_RCURLY)) @@ -2830,7 +2837,7 @@ Parse::composite_lit(Type* type, int depth, Location location) } return Expression::make_composite_literal(type, depth, has_keys, vals, - location); + all_are_names, location); } // FunctionLit = "func" Signature Block . |