* C++ PATCH to fix ICE with noexcept and -fgnu-tm (PR c++/80059)
@ 2017-03-17 14:45 Marek Polacek
2017-03-18 16:48 ` Jason Merrill
0 siblings, 1 reply; 4+ messages in thread
From: Marek Polacek @ 2017-03-17 14:45 UTC (permalink / raw)
To: GCC Patches, Jason Merrill
Paolo recently added the perform_implicit_conversion_flags call in
build_must_not_throw_expr which means that COND might now be an
IMPLICIT_CONV_EXPR. That means we need to make sure that COND is instantiated
before we try to fold it, because we can get here while parsing a template.
Me & Paolo discussed how to fix this, and I think the following is best.
Bootstrapped/regtested on x86_64-linux, ok for trunk?
2017-03-17 Marek Polacek <polacek@redhat.com>
Paolo Carlini <paolo.carlini@oracle.com>
PR c++/80059 - ICE with noexcept and __transaction_atomic
* except.c (build_must_not_throw_expr): Call
instantiate_non_dependent_expr_sfinae.
* g++.dg/tm/pr80059-2.C: New test.
* g++.dg/tm/pr80059.C: New test.
diff --git gcc/cp/except.c gcc/cp/except.c
index 45d00cc..298094e 100644
--- gcc/cp/except.c
+++ gcc/cp/except.c
@@ -271,6 +271,7 @@ build_must_not_throw_expr (tree body, tree cond)
cond = perform_implicit_conversion_flags (boolean_type_node, cond,
tf_warning_or_error,
LOOKUP_NORMAL);
+ cond = instantiate_non_dependent_expr_sfinae (cond, tf_none);
cond = cxx_constant_value (cond);
if (integer_zerop (cond))
return body;
diff --git gcc/testsuite/g++.dg/tm/pr80059-2.C gcc/testsuite/g++.dg/tm/pr80059-2.C
index e69de29..10edb3a 100644
--- gcc/testsuite/g++.dg/tm/pr80059-2.C
+++ gcc/testsuite/g++.dg/tm/pr80059-2.C
@@ -0,0 +1,13 @@
+// PR c++/80059
+// { dg-do compile { target c++11 } }
+// { dg-options "-fgnu-tm" }
+
+template<typename T> int foo(T b)
+{
+ return __transaction_atomic noexcept(b) (0); // { dg-error "is not a constant expression" }
+}
+
+void bar()
+{
+ foo(true);
+}
diff --git gcc/testsuite/g++.dg/tm/pr80059.C gcc/testsuite/g++.dg/tm/pr80059.C
index e69de29..1b705b6 100644
--- gcc/testsuite/g++.dg/tm/pr80059.C
+++ gcc/testsuite/g++.dg/tm/pr80059.C
@@ -0,0 +1,13 @@
+// PR c++/80059
+// { dg-do compile { target c++11 } }
+// { dg-options "-fgnu-tm" }
+
+template<typename> int foo(bool b)
+{
+ return __transaction_atomic noexcept(b) (0); // { dg-error "is not a constant expression" }
+}
+
+void bar()
+{
+ foo<int>(true);
+}
Marek
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: C++ PATCH to fix ICE with noexcept and -fgnu-tm (PR c++/80059)
2017-03-17 14:45 C++ PATCH to fix ICE with noexcept and -fgnu-tm (PR c++/80059) Marek Polacek
@ 2017-03-18 16:48 ` Jason Merrill
2017-03-20 14:36 ` Marek Polacek
0 siblings, 1 reply; 4+ messages in thread
From: Jason Merrill @ 2017-03-18 16:48 UTC (permalink / raw)
To: Marek Polacek; +Cc: GCC Patches
On Fri, Mar 17, 2017 at 10:45 AM, Marek Polacek <polacek@redhat.com> wrote:
> + cond = instantiate_non_dependent_expr_sfinae (cond, tf_none);
Why this rather than instantiate_non_dependent_expr (and so tf_error)?
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: C++ PATCH to fix ICE with noexcept and -fgnu-tm (PR c++/80059)
2017-03-18 16:48 ` Jason Merrill
@ 2017-03-20 14:36 ` Marek Polacek
2017-03-20 14:45 ` Jason Merrill
0 siblings, 1 reply; 4+ messages in thread
From: Marek Polacek @ 2017-03-20 14:36 UTC (permalink / raw)
To: Jason Merrill; +Cc: GCC Patches
On Sat, Mar 18, 2017 at 12:47:39PM -0400, Jason Merrill wrote:
> On Fri, Mar 17, 2017 at 10:45 AM, Marek Polacek <polacek@redhat.com> wrote:
> > + cond = instantiate_non_dependent_expr_sfinae (cond, tf_none);
>
> Why this rather than instantiate_non_dependent_expr (and so tf_error)?
Hmm, I hadn't thought about that. But now I couldn't construct a testcase
where the _sfinae version would make a difference, so here it is without
the _sfinae:
Bootstrapped/regtested on x86_64-linux, ok for trunk?
2017-03-20 Marek Polacek <polacek@redhat.com>
Paolo Carlini <paolo.carlini@oracle.com>
PR c++/80059 - ICE with noexcept and __transaction_atomic
* except.c (build_must_not_throw_expr): Call
instantiate_non_dependent_expr_sfinae.
* g++.dg/tm/pr80059-2.C: New test.
* g++.dg/tm/pr80059.C: New test.
diff --git gcc/cp/except.c gcc/cp/except.c
index 45d00cc..298094e 100644
--- gcc/cp/except.c
+++ gcc/cp/except.c
@@ -271,6 +271,7 @@ build_must_not_throw_expr (tree body, tree cond)
cond = perform_implicit_conversion_flags (boolean_type_node, cond,
tf_warning_or_error,
LOOKUP_NORMAL);
+ cond = instantiate_non_dependent_expr (cond);
cond = cxx_constant_value (cond);
if (integer_zerop (cond))
return body;
diff --git gcc/testsuite/g++.dg/tm/pr80059-2.C gcc/testsuite/g++.dg/tm/pr80059-2.C
index e69de29..10edb3a 100644
--- gcc/testsuite/g++.dg/tm/pr80059-2.C
+++ gcc/testsuite/g++.dg/tm/pr80059-2.C
@@ -0,0 +1,13 @@
+// PR c++/80059
+// { dg-do compile { target c++11 } }
+// { dg-options "-fgnu-tm" }
+
+template<typename T> int foo(T b)
+{
+ return __transaction_atomic noexcept(b) (0); // { dg-error "is not a constant expression" }
+}
+
+void bar()
+{
+ foo(true);
+}
diff --git gcc/testsuite/g++.dg/tm/pr80059.C gcc/testsuite/g++.dg/tm/pr80059.C
index e69de29..1b705b6 100644
--- gcc/testsuite/g++.dg/tm/pr80059.C
+++ gcc/testsuite/g++.dg/tm/pr80059.C
@@ -0,0 +1,13 @@
+// PR c++/80059
+// { dg-do compile { target c++11 } }
+// { dg-options "-fgnu-tm" }
+
+template<typename> int foo(bool b)
+{
+ return __transaction_atomic noexcept(b) (0); // { dg-error "is not a constant expression" }
+}
+
+void bar()
+{
+ foo<int>(true);
+}
Marek
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: C++ PATCH to fix ICE with noexcept and -fgnu-tm (PR c++/80059)
2017-03-20 14:36 ` Marek Polacek
@ 2017-03-20 14:45 ` Jason Merrill
0 siblings, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2017-03-20 14:45 UTC (permalink / raw)
To: Marek Polacek; +Cc: GCC Patches
OK.
On Mon, Mar 20, 2017 at 10:36 AM, Marek Polacek <polacek@redhat.com> wrote:
> On Sat, Mar 18, 2017 at 12:47:39PM -0400, Jason Merrill wrote:
>> On Fri, Mar 17, 2017 at 10:45 AM, Marek Polacek <polacek@redhat.com> wrote:
>> > + cond = instantiate_non_dependent_expr_sfinae (cond, tf_none);
>>
>> Why this rather than instantiate_non_dependent_expr (and so tf_error)?
>
> Hmm, I hadn't thought about that. But now I couldn't construct a testcase
> where the _sfinae version would make a difference, so here it is without
> the _sfinae:
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>
> 2017-03-20 Marek Polacek <polacek@redhat.com>
> Paolo Carlini <paolo.carlini@oracle.com>
>
> PR c++/80059 - ICE with noexcept and __transaction_atomic
> * except.c (build_must_not_throw_expr): Call
> instantiate_non_dependent_expr_sfinae.
>
> * g++.dg/tm/pr80059-2.C: New test.
> * g++.dg/tm/pr80059.C: New test.
>
> diff --git gcc/cp/except.c gcc/cp/except.c
> index 45d00cc..298094e 100644
> --- gcc/cp/except.c
> +++ gcc/cp/except.c
> @@ -271,6 +271,7 @@ build_must_not_throw_expr (tree body, tree cond)
> cond = perform_implicit_conversion_flags (boolean_type_node, cond,
> tf_warning_or_error,
> LOOKUP_NORMAL);
> + cond = instantiate_non_dependent_expr (cond);
> cond = cxx_constant_value (cond);
> if (integer_zerop (cond))
> return body;
> diff --git gcc/testsuite/g++.dg/tm/pr80059-2.C gcc/testsuite/g++.dg/tm/pr80059-2.C
> index e69de29..10edb3a 100644
> --- gcc/testsuite/g++.dg/tm/pr80059-2.C
> +++ gcc/testsuite/g++.dg/tm/pr80059-2.C
> @@ -0,0 +1,13 @@
> +// PR c++/80059
> +// { dg-do compile { target c++11 } }
> +// { dg-options "-fgnu-tm" }
> +
> +template<typename T> int foo(T b)
> +{
> + return __transaction_atomic noexcept(b) (0); // { dg-error "is not a constant expression" }
> +}
> +
> +void bar()
> +{
> + foo(true);
> +}
> diff --git gcc/testsuite/g++.dg/tm/pr80059.C gcc/testsuite/g++.dg/tm/pr80059.C
> index e69de29..1b705b6 100644
> --- gcc/testsuite/g++.dg/tm/pr80059.C
> +++ gcc/testsuite/g++.dg/tm/pr80059.C
> @@ -0,0 +1,13 @@
> +// PR c++/80059
> +// { dg-do compile { target c++11 } }
> +// { dg-options "-fgnu-tm" }
> +
> +template<typename> int foo(bool b)
> +{
> + return __transaction_atomic noexcept(b) (0); // { dg-error "is not a constant expression" }
> +}
> +
> +void bar()
> +{
> + foo<int>(true);
> +}
>
> Marek
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-03-20 14:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-17 14:45 C++ PATCH to fix ICE with noexcept and -fgnu-tm (PR c++/80059) Marek Polacek
2017-03-18 16:48 ` Jason Merrill
2017-03-20 14:36 ` Marek Polacek
2017-03-20 14:45 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).