This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, C++, PR58282] Handle noexcept on transactions with -fno-exceptions
- From: Tom de Vries <Tom_deVries at mentor dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Torvald Riegel <triegel at redhat dot com>
- Date: Fri, 6 Sep 2013 11:43:50 +0200
- Subject: Re: [PATCH, C++, PR58282] Handle noexcept on transactions with -fno-exceptions
- Authentication-results: sourceware.org; auth=none
- References: <5225B3E7 dot 8080408 at mentor dot com> <52276C0A dot 5060603 at redhat dot com>
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.
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" } } */