From: Sergei Trofimovich <slyfox@gentoo.org>
To: gcc-patches@gcc.gnu.org
Cc: Martin Sebor <msebor@gcc.gnu.org>,
Jason Merrill <jason@redhat.com>,
Sergei Trofimovich <siarheit@google.com>
Subject: [PATCH] c++: suppress all warnings on memper pointers to work around dICE [PR101219]
Date: Fri, 23 Jul 2021 00:15:24 +0100 [thread overview]
Message-ID: <20210722231524.2045951-1-slyfox@gentoo.org> (raw)
From: Sergei Trofimovich <siarheit@google.com>
r12-1804 ("cp: add support for per-location warning groups.") among other
things removed warning suppression from a few places including ptrmemfuncs.
Currently ptrmemfuncs don't have valid BINFO attached which causes ICEs
in access checks:
crash_signal
gcc/toplev.c:328
perform_or_defer_access_check(tree_node*, tree_node*, tree_node*, int, access_failure_info*)
gcc/cp/semantics.c:490
finish_non_static_data_member(tree_node*, tree_node*, tree_node*)
gcc/cp/semantics.c:2208
...
The change suppresses warnings again until we provide BINFOs for ptrmemfuncs.
PR c++/101219
gcc/cp/ChangeLog:
* typeck.c (build_ptrmemfunc_access_expr): Suppress all warnings
to avoid ICE.
gcc/testsuite/ChangeLog:
* g++.dg/torture/pr101219.C: New test.
---
gcc/cp/typeck.c | 6 +++++-
gcc/testsuite/g++.dg/torture/pr101219.C | 10 ++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/g++.dg/torture/pr101219.C
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index a483e1f988d..aa91fd21c7b 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -3326,7 +3326,11 @@ build_ptrmemfunc_access_expr (tree ptrmem, tree member_name)
member = DECL_CHAIN (member))
if (DECL_NAME (member) == member_name)
break;
- return build_simple_component_ref (ptrmem, member);
+ tree r = build_simple_component_ref (ptrmem, member);
+ /* Suppress warning to avoid exposing missing BINFO for ptrmem
+ synthetic structs: PR101219. */
+ suppress_warning(r);
+ return r;
}
/* Given an expression PTR for a pointer, return an expression
diff --git a/gcc/testsuite/g++.dg/torture/pr101219.C b/gcc/testsuite/g++.dg/torture/pr101219.C
new file mode 100644
index 00000000000..c8d30448187
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr101219.C
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-Wall" } */
+struct S { void m(); };
+
+template <int> bool f() {
+ /* In PR101219 gcc used to ICE in warning code. */
+ void (S::*mp)();
+
+ return &S::m == mp;
+}
--
2.32.0
next reply other threads:[~2021-07-22 23:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-22 23:15 Sergei Trofimovich [this message]
2021-07-23 16:33 ` Jeff Law
2021-07-23 21:32 ` Sergei Trofimovich
2021-07-29 15:41 ` Jason Merrill
2021-08-06 15:34 ` Sergei Trofimovich
2021-08-11 19:19 ` Jason Merrill
2021-08-11 22:36 ` Sergei Trofimovich
2021-08-12 14:38 ` 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=20210722231524.2045951-1-slyfox@gentoo.org \
--to=slyfox@gentoo.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
--cc=msebor@gcc.gnu.org \
--cc=siarheit@google.com \
/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).