Patchwork [C++] PR 52599

login
register
mail settings
Submitter Paolo Carlini
Date April 17, 2012, 3:35 p.m.
Message ID <4F8D8DC5.9060703@oracle.com>
Download mbox | patch
Permalink /patch/153237/
State New
Headers show

Comments

Paolo Carlini - April 17, 2012, 3:35 p.m.
Hi,
> I think build_constexpr_constructor_member_initializers is a better 
> place for that check, since it's already looking at the tree structure.
Indeed. I'm finishing testing the below. Ok if it passes?

Thanks,
Paolo.

////////////////////////
/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.

Patch

Index: testsuite/g++.dg/cpp0x/constexpr-ctor10.C
===================================================================
--- testsuite/g++.dg/cpp0x/constexpr-ctor10.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/constexpr-ctor10.C	(revision 0)
@@ -0,0 +1,6 @@ 
+// PR c++/52599
+// { dg-options -std=c++11 }
+
+struct foo {
+  constexpr foo() try { } catch(...) { };  // { dg-error "constructor" }
+};
Index: cp/semantics.c
===================================================================
--- cp/semantics.c	(revision 186523)
+++ cp/semantics.c	(working copy)
@@ -5921,6 +5921,8 @@  build_constexpr_constructor_member_initializers (t
 	    break;
 	}
     }
+  else if (TREE_CODE (body) == TRY_BLOCK)
+    error ("body of %<constexpr%> constructor cannot be a function-try-block");
   else if (EXPR_P (body))
     ok = build_data_member_initialization (body, &vec);
   else