This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Fix genericization ICE (PR c++/80984)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Nathan Sidwell <nathan at acm dot org>, Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 7 Jun 2017 11:01:01 +0200
- Subject: [C++ PATCH] Fix genericization ICE (PR c++/80984)
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E08B085359
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E08B085359
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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