From: Jason Merrill Date: Wed, 25 May 2011 19:50:49 +0000 (-0400) Subject: re PR c++/47184 ([C++0x] initialization construct interpreted as function declaration‏‏) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=636e368d17f866add3270e482e722c335b453c98;p=gcc.git re PR c++/47184 ([C++0x] initialization construct interpreted as function declaration‏‏) PR c++/47184 * parser.c (cp_parser_parameter_declaration): Recognize list-initialization. (cp_parser_direct_declarator): Check for the closing paren before parsing definitely. From-SVN: r174225 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a34926730ec..236ca6d090a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2011-05-25 Jason Merrill + PR c++/47184 + * parser.c (cp_parser_parameter_declaration): Recognize + list-initialization. + (cp_parser_direct_declarator): Check for the closing + paren before parsing definitely. + PR c++/48935 * parser.c (cp_parser_constructor_declarator_p): Don't check constructor_name_p for enums. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index db2cb96c613..004ff05768b 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -14901,6 +14901,9 @@ cp_parser_direct_declarator (cp_parser* parser, parser->num_template_parameter_lists = saved_num_template_parameter_lists; + /* Consume the `)'. */ + cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN); + /* If all went well, parse the cv-qualifier-seq and the exception-specification. */ if (member_p || cp_parser_parse_definitely (parser)) @@ -14915,8 +14918,6 @@ cp_parser_direct_declarator (cp_parser* parser, if (ctor_dtor_or_conv_p) *ctor_dtor_or_conv_p = *ctor_dtor_or_conv_p < 0; first = false; - /* Consume the `)'. */ - cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN); /* Parse the cv-qualifier-seq. */ cv_quals = cp_parser_cv_qualifier_seq_opt (parser); @@ -16053,6 +16054,7 @@ cp_parser_parameter_declaration (cp_parser *parser, of some object of type "char" to "int". */ && !parser->in_type_id_in_expr_p && cp_parser_uncommitted_to_tentative_parse_p (parser) + && cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_BRACE) && cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_PAREN)) cp_parser_commit_to_tentative_parse (parser); /* Parse the declarator. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4123c99342c..10b928f3b79 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-05-25 Jason Merrill + + * g++.dg/cpp0x/initlist51.C: New. + 2011-05-25 Janis Johnson * gcc.target/arm/fp16-compile-none-1.c: Update expected error. diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist51.C b/gcc/testsuite/g++.dg/cpp0x/initlist51.C new file mode 100644 index 00000000000..9163dd3a867 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist51.C @@ -0,0 +1,15 @@ +// PR c++/47184 +// { dg-options -std=c++0x } + +struct S +{ + int a; +}; +struct T +{ + T(S s) {} +}; +int main() +{ + T t(S{1}); +}