public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR 101515 (ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128)
@ 2022-02-08 20:11 Qing Zhao
  2022-02-08 22:20 ` Jason Merrill
  0 siblings, 1 reply; 22+ messages in thread
From: Qing Zhao @ 2022-02-08 20:11 UTC (permalink / raw)
  To: jason; +Cc: gcc-patches Paul A Clarke via

Hi, 

This is the patch to fix PR101515 (ICE in pp_cxx_unqualified_id, at  cp/cxx-pretty-print.c:128)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101515

It's possible that the TYPE_NAME of a record_type is NULL, therefore when
printing the TYPE_NAME, we should check and handle this special case.

Please see the comment of pr101515 for more details. 

The fix is very simple, just check and special handle cases when TYPE_NAME is NULL. 

Bootstrapped and regression tested on both x86 and aarch64, no issues.

Okay for commit?

Thanks.

Qing

=====================================

From f37ee8d21b80cb77d8108cb97a487c84c530545b Mon Sep 17 00:00:00 2001
From: Qing Zhao <qing.zhao@oracle.com>
Date: Tue, 8 Feb 2022 16:10:37 +0000
Subject: [PATCH] Fix PR 101515 ICE in pp_cxx_unqualified_id, at
 cp/cxx-pretty-print.c:128.

It's possible that the TYPE_NAME of a record_type is NULL, therefore when
printing the TYPE_NAME, we should check and handle this special case.

gcc/cp/ChangeLog:

	* cxx-pretty-print.cc (pp_cxx_unqualified_id): Check and handle
	the case when TYPE_NAME is NULL.

gcc/testsuite/ChangeLog:

	* g++.dg/pr101515.C: New test.
---
 gcc/cp/cxx-pretty-print.cc      |  5 ++++-
 gcc/testsuite/g++.dg/pr101515.C | 25 +++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/pr101515.C

diff --git a/gcc/cp/cxx-pretty-print.cc b/gcc/cp/cxx-pretty-print.cc
index 4f9a090e520d..744ed0add5ba 100644
--- a/gcc/cp/cxx-pretty-print.cc
+++ b/gcc/cp/cxx-pretty-print.cc
@@ -171,7 +171,10 @@ pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t)
     case ENUMERAL_TYPE:
     case TYPENAME_TYPE:
     case UNBOUND_CLASS_TEMPLATE:
-      pp_cxx_unqualified_id (pp, TYPE_NAME (t));
+      if (TYPE_NAME (t))
+	pp_cxx_unqualified_id (pp, TYPE_NAME (t));
+      else
+	pp_string (pp, "<unnamed type>");
       if (tree ti = TYPE_TEMPLATE_INFO_MAYBE_ALIAS (t))
 	if (PRIMARY_TEMPLATE_P (TI_TEMPLATE (ti)))
 	  {
diff --git a/gcc/testsuite/g++.dg/pr101515.C b/gcc/testsuite/g++.dg/pr101515.C
new file mode 100644
index 000000000000..898c7e003c22
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr101515.C
@@ -0,0 +1,25 @@
+/* PR101515 -  ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 
+   { dg-do compile }
+   { dg-options "-Wuninitialized -O1" } */
+
+struct S
+{
+  int j;
+};
+struct T : public S
+{
+  virtual void h () {}
+};
+struct ptrmemfunc
+{
+  void (*ptr) ();
+};
+typedef void (S::*sp)();
+int main ()
+{
+  T t;
+  sp x;
+  ptrmemfunc *xp = (ptrmemfunc *) &x;
+  if (xp->ptr != ((void (*)())(sizeof(void *))))  /* { dg-warning "is used uninitialized" } */
+    return 1;
+}
-- 
2.27.0




^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2022-03-19  5:32 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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               ` [PATCH] c-family: Fix ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 [PR101515] Jakub Jelinek

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).