diff options
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/parser.c | 31 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/complit13.C | 11 |
4 files changed, 36 insertions, 17 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 73b8debbf04..dd53e69d938 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-05-20 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/10207 + * parser.c (cp_parser_postfix_expression): Use cp_parser_braced_list + instead of cp_parser_initializer_list for compound-literals. + 2013-05-20 Marc Glisse <marc.glisse@inria.fr> PR c++/57175 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 022886e37b6..91e6615ae38 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -5719,7 +5719,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, if (cp_parser_allow_gnu_extensions_p (parser) && cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN)) { - vec<constructor_elt, va_gc> *initializer_list = NULL; + tree initializer = NULL_TREE; bool saved_in_type_id_in_expr_p; cp_parser_parse_tentatively (parser); @@ -5732,21 +5732,19 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p; /* Look for the `)'. */ cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN); - /* Look for the `{'. */ - cp_parser_require (parser, CPP_OPEN_BRACE, RT_OPEN_BRACE); /* If things aren't going well, there's no need to keep going. */ if (!cp_parser_error_occurred (parser)) { - bool non_constant_p; - /* Parse the initializer-list. */ - initializer_list - = cp_parser_initializer_list (parser, &non_constant_p); - /* Allow a trailing `,'. */ - if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA)) - cp_lexer_consume_token (parser->lexer); - /* Look for the final `}'. */ - cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE); + if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) + { + bool non_constant_p; + /* Parse the brace-enclosed initializer list. */ + initializer = cp_parser_braced_list (parser, + &non_constant_p); + } + else + cp_parser_simulate_error (parser); } /* If that worked, we're definitely looking at a compound-literal expression. */ @@ -5754,7 +5752,8 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, { /* Warn the user that a compound literal is not allowed in standard C++. */ - pedwarn (input_location, OPT_Wpedantic, "ISO C++ forbids compound-literals"); + pedwarn (input_location, OPT_Wpedantic, + "ISO C++ forbids compound-literals"); /* For simplicity, we disallow compound literals in constant-expressions. We could allow compound literals of integer type, whose @@ -5772,10 +5771,8 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, } /* Form the representation of the compound-literal. */ postfix_expression - = (finish_compound_literal - (type, build_constructor (init_list_type_node, - initializer_list), - tf_warning_or_error)); + = finish_compound_literal (type, initializer, + tf_warning_or_error); break; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5a113d71429..dfde009de2a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-05-20 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/10207 + * g++.dg/ext/complit13.C: New. + 2013-05-20 Marc Glisse <marc.glisse@inria.fr> PR c++/57175 diff --git a/gcc/testsuite/g++.dg/ext/complit13.C b/gcc/testsuite/g++.dg/ext/complit13.C new file mode 100644 index 00000000000..c12678ba864 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/complit13.C @@ -0,0 +1,11 @@ +// PR c++/10207 +// { dg-options "" } + +typedef struct { } EmptyStruct; +typedef struct { EmptyStruct Empty; } DemoStruct; + +void Func() +{ + DemoStruct Demo; + Demo.Empty = (EmptyStruct) {}; +} |