* [C++ PATCH] Fix genericization ICE (PR c++/80984)
@ 2017-06-07 9:01 Jakub Jelinek
2017-06-12 20:46 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2017-06-07 9:01 UTC (permalink / raw)
To: Nathan Sidwell, Jason Merrill; +Cc: gcc-patches
Hi!
As the testcase shows, BLOCK_VARS of the outermost scope can contain
decls other than VAR_DECL that have DECL_NAME identical to what we are
looking for, in this case a LABEL_DECL. The code is looking for the
VAR_DECL that has been NRV optimized, and while e.g. DECL_HAS_VALUE_EXPR_P
is allowed on all of VAR_DECL, PARM_DECL and RESULT_DECL, BLOCK_VARS
should not contain the latter two.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk and
release branches?
2017-06-07 Jakub Jelinek <jakub@redhat.com>
PR c++/80984
* cp-gimplify.c (cp_genericize): Only look for VAR_DECLs in
BLOCK_VARS (outer) chain.
(cxx_omp_const_qual_no_mutable): Likewise.
* g++.dg/opt/nrv18.C: New test.
--- gcc/cp/cp-gimplify.c.jj 2017-05-22 20:49:04.000000000 +0200
+++ gcc/cp/cp-gimplify.c 2017-06-06 10:11:22.780850949 +0200
@@ -1590,7 +1590,8 @@ cp_genericize (tree fndecl)
if (outer)
for (var = BLOCK_VARS (outer); var; var = DECL_CHAIN (var))
- if (DECL_NAME (t) == DECL_NAME (var)
+ if (VAR_P (var)
+ && DECL_NAME (t) == DECL_NAME (var)
&& DECL_HAS_VALUE_EXPR_P (var)
&& DECL_VALUE_EXPR (var) == t)
{
@@ -1837,7 +1838,8 @@ cxx_omp_const_qual_no_mutable (tree decl
if (outer)
for (var = BLOCK_VARS (outer); var; var = DECL_CHAIN (var))
- if (DECL_NAME (decl) == DECL_NAME (var)
+ if (VAR_P (var)
+ && DECL_NAME (decl) == DECL_NAME (var)
&& (TYPE_MAIN_VARIANT (type)
== TYPE_MAIN_VARIANT (TREE_TYPE (var))))
{
--- gcc/testsuite/g++.dg/opt/nrv18.C.jj 2017-06-06 10:13:00.925650648 +0200
+++ gcc/testsuite/g++.dg/opt/nrv18.C 2017-06-06 10:12:10.670265267 +0200
@@ -0,0 +1,12 @@
+// PR c++/80984
+// { dg-do compile }
+
+struct A { ~A (); };
+
+A
+foo ()
+{
+ A a;
+a:
+ return a;
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [C++ PATCH] Fix genericization ICE (PR c++/80984)
2017-06-07 9:01 [C++ PATCH] Fix genericization ICE (PR c++/80984) Jakub Jelinek
@ 2017-06-12 20:46 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2017-06-12 20:46 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Nathan Sidwell, gcc-patches List
OK.
On Wed, Jun 7, 2017 at 2:01 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> As the testcase shows, BLOCK_VARS of the outermost scope can contain
> decls other than VAR_DECL that have DECL_NAME identical to what we are
> looking for, in this case a LABEL_DECL. The code is looking for the
> VAR_DECL that has been NRV optimized, and while e.g. DECL_HAS_VALUE_EXPR_P
> is allowed on all of VAR_DECL, PARM_DECL and RESULT_DECL, BLOCK_VARS
> should not contain the latter two.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk and
> release branches?
>
> 2017-06-07 Jakub Jelinek <jakub@redhat.com>
>
> PR c++/80984
> * cp-gimplify.c (cp_genericize): Only look for VAR_DECLs in
> BLOCK_VARS (outer) chain.
> (cxx_omp_const_qual_no_mutable): Likewise.
>
> * g++.dg/opt/nrv18.C: New test.
>
> --- gcc/cp/cp-gimplify.c.jj 2017-05-22 20:49:04.000000000 +0200
> +++ gcc/cp/cp-gimplify.c 2017-06-06 10:11:22.780850949 +0200
> @@ -1590,7 +1590,8 @@ cp_genericize (tree fndecl)
>
> if (outer)
> for (var = BLOCK_VARS (outer); var; var = DECL_CHAIN (var))
> - if (DECL_NAME (t) == DECL_NAME (var)
> + if (VAR_P (var)
> + && DECL_NAME (t) == DECL_NAME (var)
> && DECL_HAS_VALUE_EXPR_P (var)
> && DECL_VALUE_EXPR (var) == t)
> {
> @@ -1837,7 +1838,8 @@ cxx_omp_const_qual_no_mutable (tree decl
>
> if (outer)
> for (var = BLOCK_VARS (outer); var; var = DECL_CHAIN (var))
> - if (DECL_NAME (decl) == DECL_NAME (var)
> + if (VAR_P (var)
> + && DECL_NAME (decl) == DECL_NAME (var)
> && (TYPE_MAIN_VARIANT (type)
> == TYPE_MAIN_VARIANT (TREE_TYPE (var))))
> {
> --- gcc/testsuite/g++.dg/opt/nrv18.C.jj 2017-06-06 10:13:00.925650648 +0200
> +++ gcc/testsuite/g++.dg/opt/nrv18.C 2017-06-06 10:12:10.670265267 +0200
> @@ -0,0 +1,12 @@
> +// PR c++/80984
> +// { dg-do compile }
> +
> +struct A { ~A (); };
> +
> +A
> +foo ()
> +{
> + A a;
> +a:
> + return a;
> +}
>
> Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-12 20:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-07 9:01 [C++ PATCH] Fix genericization ICE (PR c++/80984) Jakub Jelinek
2017-06-12 20:46 ` 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).