public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Fix printing of function names in dumps
@ 2008-11-06 11:43 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2008-11-06 11:43 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 309 bytes --]

The problem is that gnat_printable_name returns the address of a static buffer 
in some cases.

Tested on x86_64-suse-linux, applied on the mainline.


2008-11-06  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/misc.c (gnat_printable_name): Always return a copy
	in GC memory.


-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-diff, Size: 565 bytes --]

Index: gcc-interface/misc.c
===================================================================
--- gcc-interface/misc.c	(revision 141548)
+++ gcc-interface/misc.c	(working copy)
@@ -603,10 +603,10 @@ gnat_printable_name (tree decl, int verb
   if (verbosity == 2)
     {
       Set_Identifier_Casing (ada_name, (char *) DECL_SOURCE_FILE (decl));
-      ada_name = Name_Buffer;
+      return ggc_strdup (Name_Buffer);
     }
-
-  return (const char *) ada_name;
+  else
+    return ada_name;
 }
 
 /* Expands GNAT-specific GCC tree nodes.  The only ones we support

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-11-06 11:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-06 11:43 [Ada] Fix printing of function names in dumps Eric Botcazou

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