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 <t...@codesourcery.com> PR c++/58282 * except.c (build_must_not_throw_expr): Handle flag_exceptions. * g++.dg/tm/noexcept-6.C: New test.
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" } } */