From: Jakub Jelinek <jakub@redhat.com>
To: Jason Merrill <jason@redhat.com>,
gcc-patches Paul A Clarke via <gcc-patches@gcc.gnu.org>
Subject: [PATCH] c-family: Fix ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 [PR101515]
Date: Wed, 16 Mar 2022 11:29:20 +0100 [thread overview]
Message-ID: <YjG8AGvAyf6xZFgT@tucnak> (raw)
In-Reply-To: <YjCHbjUR7Q3/z3+a@tucnak>
On Tue, Mar 15, 2022 at 01:32:46PM +0100, Jakub Jelinek via Gcc-patches wrote:
> Another one is whether we shouldn't punt for FIELD_DECLs that don't have
> nicely printable name of its containing scope, something like:
> if (tree scope = get_containing_scope (field))
> if (TYPE_P (scope) && TYPE_NAME (scope) == NULL_TREE)
> break;
> return cop;
> or so.
This seems to work fine, ok if it passes bootstrap/regtest?
No need to do it for C because it doesn't print the contexts (has no syntax
for that even).
2022-03-16 Jakub Jelinek <jakub@redhat.com>
PR c++/101515
* c-pretty-print.cc (c_fold_indirect_ref_for_warn): For C++ don't
return COMPONENT_REFs with FIELD_DECLs whose containing scope can't
be printed.
* g++.dg/warn/pr101515.C: New test.
--- gcc/c-family/c-pretty-print.cc.jj 2022-02-14 13:14:39.037128630 +0100
+++ gcc/c-family/c-pretty-print.cc 2022-03-16 11:16:54.957658064 +0100
@@ -1889,6 +1889,12 @@ c_fold_indirect_ref_for_warn (location_t
= wi::to_offset (TYPE_SIZE_UNIT (TREE_TYPE (field)));
if (upos <= off && off < upos + el_sz)
{
+ /* The C++ pretty printers print scope of the FIELD_DECLs,
+ so punt if it is something that can't be printed. */
+ if (c_dialect_cxx ())
+ if (tree scope = get_containing_scope (field))
+ if (TYPE_P (scope) && TYPE_NAME (scope) == NULL_TREE)
+ break;
tree cop = build3_loc (loc, COMPONENT_REF, TREE_TYPE (field),
op, field, NULL_TREE);
off = off - upos;
--- gcc/testsuite/g++.dg/warn/pr101515.C.jj 2022-03-16 11:19:09.004806778 +0100
+++ gcc/testsuite/g++.dg/warn/pr101515.C 2022-03-16 11:24:35.136302673 +0100
@@ -0,0 +1,18 @@
+// PR c++/101515
+// { dg-do compile }
+// { dg-options "-O1 -Wuninitialized" }
+
+struct S { int j; };
+struct T : public S { virtual void h () {} };
+struct U { void (*ptr) (); };
+typedef void (S::*sp) ();
+
+int
+main ()
+{
+ T t;
+ sp x;
+ U *xp = (U *) &x;
+ if (xp->ptr != ((void (*) ()) (sizeof (void *)))) // { dg-warning "is used uninitialized" }
+ return 1;
+}
Jakub
prev parent reply other threads:[~2022-03-16 10:29 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-08 20:11 [PATCH] Fix PR 101515 (ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128) Qing Zhao
2022-02-08 22:20 ` Jason Merrill
2022-02-09 15:51 ` Qing Zhao
2022-02-09 18:23 ` Jason Merrill
2022-02-09 21:01 ` Qing Zhao
2022-02-10 2:49 ` Jason Merrill
2022-02-11 16:07 ` Qing Zhao
2022-02-11 17:27 ` Jason Merrill
2022-02-11 18:11 ` Qing Zhao
2022-02-11 19:39 ` Jason Merrill
2022-02-11 20:29 ` Qing Zhao
2022-02-11 21:54 ` Jason Merrill
2022-02-11 22:19 ` Qing Zhao
2022-03-15 12:32 ` Jakub Jelinek
2022-03-15 15:57 ` Jason Merrill
2022-03-15 16:06 ` Jakub Jelinek
2022-03-18 17:35 ` Jason Merrill
2022-03-18 18:20 ` Jakub Jelinek
2022-03-18 18:27 ` Jason Merrill
2022-03-18 18:47 ` Jakub Jelinek
2022-03-19 5:32 ` Jason Merrill
2022-03-16 10:29 ` Jakub Jelinek [this message]
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=YjG8AGvAyf6xZFgT@tucnak \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.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).