From: Jakub Jelinek <jakub@redhat.com>
To: Nathan Sidwell <nathan@acm.org>, Jason Merrill <jason@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: [C++ PATCH] Fix genericization ICE (PR c++/80984)
Date: Wed, 07 Jun 2017 09:01:00 -0000 [thread overview]
Message-ID: <20170607090101.GQ2154@tucnak> (raw)
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
next reply other threads:[~2017-06-07 9:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-07 9:01 Jakub Jelinek [this message]
2017-06-12 20:46 ` Jason Merrill
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170607090101.GQ2154@tucnak \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
--cc=nathan@acm.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).