diff mbox

[C++,PR58282] Handle noexcept on transactions with -fno-exceptions

Message ID 5229A3D6.1060609@mentor.com
State New
Headers show

Commit Message

Tom de Vries Sept. 6, 2013, 9:43 a.m. UTC
On 04/09/13 19:21, Jason Merrill wrote:
> On 09/03/2013 06:03 AM, Tom de Vries wrote:
>> 	* semantics.c (finish_transaction_stmt, build_transaction_expr): Handle
>> 	flag_exceptions.
> 
> I'd rather handle this at a lower level, by making 
> build_must_not_throw_expr return its argument if -fno-exceptions.
> 

Jason,

This patch implements that way of fixing. In addition, it adds a test-case.

Bootstrapped and reg-tested on x86_64.

OK for trunk?

Thanks,
- Tom


2013-09-02  Tom de Vries  <tom@codesourcery.com>

	PR c++/58282
	* except.c (build_must_not_throw_expr): Handle
	flag_exceptions.

	* g++.dg/tm/noexcept-6.C: New test.

Comments

Jason Merrill Sept. 7, 2013, 4:54 p.m. UTC | #1
OK.

Jason
Tom de Vries Oct. 25, 2013, 2:25 p.m. UTC | #2
On 07/09/13 18:54, Jason Merrill wrote:
> OK.
> 

I've reproduced the same problem with the 4.7 and 4.8 branch, and checked that
applying the patch fixes the problem.

Committed to 4.7 and 4.8 branch as well.

Thanks,
- Tom
diff mbox

Patch

diff --git a/gcc/cp/except.c b/gcc/cp/except.c
index fbebcba..c76d944 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -374,6 +374,9 @@  build_must_not_throw_expr (tree body, tree cond)
 {
   tree type = body ? TREE_TYPE (body) : void_type_node;
 
+  if (!flag_exceptions)
+    return body;
+
   if (cond && !value_dependent_expression_p (cond))
     {
       cond = cxx_constant_value (cond);
diff --git a/gcc/testsuite/g++.dg/tm/noexcept-6.C b/gcc/testsuite/g++.dg/tm/noexcept-6.C
new file mode 100644
index 0000000..4391159
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tm/noexcept-6.C
@@ -0,0 +1,23 @@ 
+// { dg-do compile }
+// { dg-options "-fno-exceptions -fgnu-tm -O -std=c++0x -fdump-tree-tmlower" }
+
+struct TrueFalse
+{
+  static constexpr bool v() { return true; }
+};
+
+int global;
+
+template<typename T> int foo()
+{
+  return __transaction_atomic noexcept(T::v()) (global + 1);
+}
+
+int f1()
+{
+  return foo<TrueFalse>();
+}
+
+/* { dg-final { scan-tree-dump-times "eh_must_not_throw" 0 "tmlower" } } */
+/* { dg-final { scan-tree-dump-times "__transaction_atomic" 1 "tmlower" } } */
+/* { dg-final { cleanup-tree-dump "tmlower" } } */