re PR c++/52599 (ICE on illegal constexpr constructor declaration)
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 17 Apr 2012 17:20:02 +0000 (17:20 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 17 Apr 2012 17:20:02 +0000 (17:20 +0000)
/cp
2012-04-17  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/52599
* semantics.c (build_constexpr_constructor_member_initializers):
Check for function-try-block as function-body.

/testsuite
2012-04-17  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/52599
* g++.dg/cpp0x/constexpr-ctor10.C: New.

/cp
2012-04-17  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/53003
* parser.c (cp_parser_member_declaration): Check that
initializer_token_start is non null before dereferencing it.

/testsuite
2012-04-17  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/53003
* g++.dg/parse/crash59.C: New.

From-SVN: r186541

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-ctor10.C [new file with mode: 0644]
gcc/testsuite/g++.dg/parse/crash59.C [new file with mode: 0644]

index 8746c64..16dceec 100644 (file)
@@ -1,3 +1,15 @@
+2012-04-17  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/52599
+       * semantics.c (build_constexpr_constructor_member_initializers):
+       Check for function-try-block as function-body.
+
+2012-04-17  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/53003
+       * parser.c (cp_parser_member_declaration): Check that
+       initializer_token_start is non null before dereferencing it.
+
 2012-04-16  Jason Merrill  <jason@redhat.com>
 
        PR c++/38543
index 6809bc7..8aefefa 100644 (file)
@@ -19109,7 +19109,7 @@ cp_parser_member_declaration (cp_parser* parser)
                     possible that this fact is an oversight in the
                     standard, since a pure function may be defined
                     outside of the class-specifier.  */
-                 if (initializer)
+                 if (initializer && initializer_token_start)
                    error_at (initializer_token_start->location,
                              "pure-specifier on function-definition");
                  decl = cp_parser_save_member_function_body (parser,
index 9bdd2ee..22185ea 100644 (file)
@@ -5921,6 +5921,12 @@ build_constexpr_constructor_member_initializers (tree type, tree body)
            break;
        }
     }
+  else if (TREE_CODE (body) == TRY_BLOCK)
+    {
+      error ("body of %<constexpr%> constructor cannot be "
+            "a function-try-block");
+      return error_mark_node;
+    }
   else if (EXPR_P (body))
     ok = build_data_member_initialization (body, &vec);
   else
index 301f561..0c42dee 100644 (file)
@@ -1,3 +1,13 @@
+2012-04-17  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/52599
+       * g++.dg/cpp0x/constexpr-ctor10.C: New.
+
+2012-04-17  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/53003
+       * g++.dg/parse/crash59.C: New.
+
 2012-04-17  Michael Matz  <matz@suse.de>
 
        PR tree-optimization/18437
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor10.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor10.C
new file mode 100644 (file)
index 0000000..c1279e2
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/52599
+// { dg-options -std=c++11 }
+
+struct foo {
+  constexpr foo() try { } catch(...) { };  // { dg-error "constructor" }
+};
diff --git a/gcc/testsuite/g++.dg/parse/crash59.C b/gcc/testsuite/g++.dg/parse/crash59.C
new file mode 100644 (file)
index 0000000..e5e6298
--- /dev/null
@@ -0,0 +1,3 @@
+// PR c++/53003
+
+struct A{ void a{} return b  // { dg-error "function definition|expected" }