public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] Fix ICEs when DEBUG_MANGLE is enabled
@ 2013-11-13 20:27 Cary Coutant
  2013-11-14 10:02 ` Dodji Seketeli
  2013-11-19 22:37 ` Cary Coutant
  0 siblings, 2 replies; 5+ messages in thread
From: Cary Coutant @ 2013-11-13 20:27 UTC (permalink / raw)
  To: gcc-patches

This patch fixes a few ICEs I encountered when enabling DEBUG_MANGLE.
I've also changed dump_substitution_candidates to output the substitution
index in base 36, to match the actual mangled name.

OK for trunk?

-cary


2013-11-13  Cary Coutant  <ccoutant@google.com>

gcc/
	* cp/mangle.c (to_base36): New function.
	(dump_substitution_candidates): Add checks for NULL.
        Print substitution index in base 36.


commit 5ece725d55f104dd6499ac261380a9c9c4002613
Author: Cary Coutant <ccoutant@google.com>
Date:   Wed Nov 13 09:28:58 2013 -0800

    Fix ICEs when DEBUG_MANGLE is enabled.

diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 202fafc..56c1844 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -301,6 +301,19 @@ decl_is_template_id (const tree decl, tree* const template_info)
   return 0;
 }
 
+/* Convert VAL to base 36.  */
+
+static const char *
+to_base36 (int val)
+{
+  static char buffer[sizeof (HOST_WIDE_INT) * 8 + 1];
+  unsigned count;
+
+  count = hwint_to_ascii (number, 36, buffer + sizeof (buffer) - 1, 1);
+  buffer[sizeof (buffer) - 1] = '\0';
+  return buffer + sizeof (buffer) - 1 - count;
+}
+
 /* Produce debugging output of current substitution candidates.  */
 
 static void
@@ -317,12 +330,27 @@ dump_substitution_candidates (void)
       if (i > 0)
 	fprintf (stderr, "                    ");
       if (DECL_P (el))
-	name = IDENTIFIER_POINTER (DECL_NAME (el));
+        {
+          if (DECL_NAME (el))
+            name = IDENTIFIER_POINTER (DECL_NAME (el));
+        }
       else if (TREE_CODE (el) == TREE_LIST)
-	name = IDENTIFIER_POINTER (DECL_NAME (TREE_VALUE (el)));
+        {
+          tree val = TREE_VALUE (el);
+          if (TREE_CODE (val) == IDENTIFIER_NODE)
+            name = IDENTIFIER_POINTER (val);
+          else if (DECL_P (val))
+            name = IDENTIFIER_POINTER (DECL_NAME (val));
+        }
       else if (TYPE_NAME (el))
-	name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (el)));
-      fprintf (stderr, " S%d_ = ", i - 1);
+        {
+          if (DECL_NAME (TYPE_NAME (el)))
+            name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (el)));
+        }
+      if (i == 0)
+        fprintf (stderr, " S_ = ");
+      else
+        fprintf (stderr, " S%s_ = ", to_base36 (i - 1));
       if (TYPE_P (el) &&
 	  (CP_TYPE_RESTRICT_P (el)
 	   || CP_TYPE_VOLATILE_P (el)

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

* Re: [patch] Fix ICEs when DEBUG_MANGLE is enabled
  2013-11-13 20:27 [patch] Fix ICEs when DEBUG_MANGLE is enabled Cary Coutant
@ 2013-11-14 10:02 ` Dodji Seketeli
  2013-11-14 10:06   ` Jakub Jelinek
  2013-11-19 22:37 ` Cary Coutant
  1 sibling, 1 reply; 5+ messages in thread
From: Dodji Seketeli @ 2013-11-14 10:02 UTC (permalink / raw)
  To: Cary Coutant; +Cc: gcc-patches, Jason Merrill

I guess we should CC Jason for this ...

ccoutant@google.com (Cary Coutant) a écrit:

This patch fixes a few ICEs I encountered when enabling DEBUG_MANGLE.
I've also changed dump_substitution_candidates to output the substitution
index in base 36, to match the actual mangled name.

OK for trunk?

-cary


2013-11-13  Cary Coutant  <ccoutant@google.com>

gcc/
	* cp/mangle.c (to_base36): New function.
	(dump_substitution_candidates): Add checks for NULL.
        Print substitution index in base 36.


commit 5ece725d55f104dd6499ac261380a9c9c4002613
Author: Cary Coutant <ccoutant@google.com>
Date:   Wed Nov 13 09:28:58 2013 -0800

    Fix ICEs when DEBUG_MANGLE is enabled.

diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 202fafc..56c1844 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -301,6 +301,19 @@ decl_is_template_id (const tree decl, tree* const template_info)
   return 0;
 }
 
+/* Convert VAL to base 36.  */
+
+static const char *
+to_base36 (int val)
+{
+  static char buffer[sizeof (HOST_WIDE_INT) * 8 + 1];
+  unsigned count;
+
+  count = hwint_to_ascii (number, 36, buffer + sizeof (buffer) - 1, 1);
+  buffer[sizeof (buffer) - 1] = '\0';
+  return buffer + sizeof (buffer) - 1 - count;
+}
+
 /* Produce debugging output of current substitution candidates.  */
 
 static void
@@ -317,12 +330,27 @@ dump_substitution_candidates (void)
       if (i > 0)
 	fprintf (stderr, "                    ");
       if (DECL_P (el))
-	name = IDENTIFIER_POINTER (DECL_NAME (el));
+        {
+          if (DECL_NAME (el))
+            name = IDENTIFIER_POINTER (DECL_NAME (el));
+        }
       else if (TREE_CODE (el) == TREE_LIST)
-	name = IDENTIFIER_POINTER (DECL_NAME (TREE_VALUE (el)));
+        {
+          tree val = TREE_VALUE (el);
+          if (TREE_CODE (val) == IDENTIFIER_NODE)
+            name = IDENTIFIER_POINTER (val);
+          else if (DECL_P (val))
+            name = IDENTIFIER_POINTER (DECL_NAME (val));
+        }
       else if (TYPE_NAME (el))
-	name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (el)));
-      fprintf (stderr, " S%d_ = ", i - 1);
+        {
+          if (DECL_NAME (TYPE_NAME (el)))
+            name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (el)));
+        }
+      if (i == 0)
+        fprintf (stderr, " S_ = ");
+      else
+        fprintf (stderr, " S%s_ = ", to_base36 (i - 1));
       if (TYPE_P (el) &&
 	  (CP_TYPE_RESTRICT_P (el)
 	   || CP_TYPE_VOLATILE_P (el)

-- 
		Dodji

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

* Re: [patch] Fix ICEs when DEBUG_MANGLE is enabled
  2013-11-14 10:02 ` Dodji Seketeli
@ 2013-11-14 10:06   ` Jakub Jelinek
  0 siblings, 0 replies; 5+ messages in thread
From: Jakub Jelinek @ 2013-11-14 10:06 UTC (permalink / raw)
  To: Dodji Seketeli; +Cc: Cary Coutant, gcc-patches, Jason Merrill

On Thu, Nov 14, 2013 at 09:03:02AM +0100, Dodji Seketeli wrote:
> I guess we should CC Jason for this ...
> 
> ccoutant@google.com (Cary Coutant) a écrit:
> 
> This patch fixes a few ICEs I encountered when enabling DEBUG_MANGLE.
> I've also changed dump_substitution_candidates to output the substitution
> index in base 36, to match the actual mangled name.
> 
> OK for trunk?
> 
> -cary
> 
> 
> 2013-11-13  Cary Coutant  <ccoutant@google.com>
> 
> gcc/
> 	* cp/mangle.c (to_base36): New function.

Just a nit, cp/ doesn't belong here and it should go to gcc/cp/ChangeLog.
And the last line of ChangeLog has spaces instead of tabs.

> 	(dump_substitution_candidates): Add checks for NULL.
>         Print substitution index in base 36.

	Jakub

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

* Re: [patch] Fix ICEs when DEBUG_MANGLE is enabled
  2013-11-13 20:27 [patch] Fix ICEs when DEBUG_MANGLE is enabled Cary Coutant
  2013-11-14 10:02 ` Dodji Seketeli
@ 2013-11-19 22:37 ` Cary Coutant
  2013-11-23 19:22   ` Jason Merrill
  1 sibling, 1 reply; 5+ messages in thread
From: Cary Coutant @ 2013-11-19 22:37 UTC (permalink / raw)
  To: gcc-patches, Jason Merrill

> 2013-11-13  Cary Coutant  <ccoutant@google.com>
>
> gcc/cp/
>         * mangle.c (to_base36): New function.
>         (dump_substitution_candidates): Add checks for NULL.
>         Print substitution index in base 36.

Ping?

-cary

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

* Re: [patch] Fix ICEs when DEBUG_MANGLE is enabled
  2013-11-19 22:37 ` Cary Coutant
@ 2013-11-23 19:22   ` Jason Merrill
  0 siblings, 0 replies; 5+ messages in thread
From: Jason Merrill @ 2013-11-23 19:22 UTC (permalink / raw)
  To: Cary Coutant, gcc-patches

OK.

Jason

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

end of thread, other threads:[~2013-11-23 19:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-13 20:27 [patch] Fix ICEs when DEBUG_MANGLE is enabled Cary Coutant
2013-11-14 10:02 ` Dodji Seketeli
2013-11-14 10:06   ` Jakub Jelinek
2013-11-19 22:37 ` Cary Coutant
2013-11-23 19:22   ` Jason Merrill

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