re PR c++/57682 (Uniform initialization syntax rejected in function-try-block)
authorPaolo Carlini <paolo.carlini@oracle.com>
Fri, 28 Jun 2013 08:53:03 +0000 (08:53 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 28 Jun 2013 08:53:03 +0000 (08:53 +0000)
/cp
2013-06-28  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/57682
* parser.c (cp_parser_save_member_function_body): Handle correctly
curly braces in function-try-block mem-initializers.

/testsuite
2013-06-28  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/57682
* g++.dg/cpp0x/initlist73.C: New.

From-SVN: r200504

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

index 4f74133c2e7521b01e55782d17fae2e58b0bc7be..120247d641e573caad5470c540925899d02bb6e4 100644 (file)
@@ -1,3 +1,9 @@
+2013-06-28  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/57682
+       * parser.c (cp_parser_save_member_function_body): Handle correctly
+       curly braces in function-try-block mem-initializers.
+
 2013-06-27  Marc Glisse  <marc.glisse@inria.fr>
 
        PR c++/57509
index ad2fe257731a9d7ce2262d7c3455d97685165053..c6ecf69e50e9852fb808ca2a72d0c06e4efdb4f7 100644 (file)
@@ -22798,12 +22798,14 @@ cp_parser_save_member_function_body (cp_parser* parser,
   /* Save away the tokens that make up the body of the
      function.  */
   first = parser->lexer->next_token;
+  /* Handle function try blocks.  */
+  if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TRY))
+    cp_lexer_consume_token (parser->lexer);
   /* We can have braced-init-list mem-initializers before the fn body.  */
   if (cp_lexer_next_token_is (parser->lexer, CPP_COLON))
     {
       cp_lexer_consume_token (parser->lexer);
-      while (cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_BRACE)
-            && cp_lexer_next_token_is_not_keyword (parser->lexer, RID_TRY))
+      while (cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_BRACE))
        {
          /* cache_group will stop after an un-nested { } pair, too.  */
          if (cp_parser_cache_group (parser, CPP_CLOSE_PAREN, /*depth=*/0))
index ee5615e4817a15c4dcad70fcc414717fcf9c116d..2c2443f6a1e8bc3216542a411186681bf51358b2 100644 (file)
@@ -1,3 +1,8 @@
+2013-06-28  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/57682
+       * g++.dg/cpp0x/initlist73.C: New.
+
 2013-06-27  Meador Inge  <meadori@codesourcery.com>
 
        * gcc.dg/atomic-flag.c: Add dg-require-effective-target sync_*.
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist73.C b/gcc/testsuite/g++.dg/cpp0x/initlist73.C
new file mode 100644 (file)
index 0000000..de9748d
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/57682
+// { dg-do compile { target c++11 } }
+
+struct Class
+{
+  Class (int func)
+  try
+  : f { func }  { }
+  catch ( ... ) { }
+
+private:
+  int f;
+};