re PR c++/47184 ([C++0x] initialization construct interpreted as function declaration‏‏)
authorJason Merrill <jason@redhat.com>
Wed, 25 May 2011 19:50:49 +0000 (15:50 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 25 May 2011 19:50:49 +0000 (15:50 -0400)
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

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/initlist51.C [new file with mode: 0644]

index a34926730ec7d32dda7ab056b6aee28372784dc6..236ca6d090a7041e6829401f736621b3b76434b3 100644 (file)
@@ -1,5 +1,11 @@
 2011-05-25  Jason Merrill  <jason@redhat.com>
 
+       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.
index db2cb96c6138b36125369334af44634abdc45760..004ff05768beca1378f4ae8821eaf9ec2b4529d0 100644 (file)
@@ -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.  */
index 4123c99342ca3fc36d7c5e29281c9572c357362d..10b928f3b793195467bc01bd46a5407476053e59 100644 (file)
@@ -1,3 +1,7 @@
+2011-05-25  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/initlist51.C: New.
+
 2011-05-25  Janis Johnson  <janisjo@codesourcery.com>
 
        * 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 (file)
index 0000000..9163dd3
--- /dev/null
@@ -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});
+}