This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Ada PATCH] Clean-up Ada front-end use of TREE_OVERFLOW
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: Gabriel Dos Reis <gdr at integrable-solutions dot net>, Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>, gcc-patches at gcc dot gnu dot org
- Date: Sat, 19 Nov 2005 15:54:50 +0100
- Subject: Re: [Ada PATCH] Clean-up Ada front-end use of TREE_OVERFLOW
- References: <m3br7bvs14.fsf@uniton.integrable-solutions.net> <Pine.LNX.4.44.0505152106520.24236-100000@www.eyesopen.com>
On 5/16/05, Roger Sayle <roger@eyesopen.com> wrote:
>
> On 16 May 2005, Gabriel Dos Reis wrote:
> > The changes look OK, with the caveat that the pretty_printer object
> > should probably be constructed as part of gnat1 startup
> > initialization, instead of waiting for the first call to abort where
> > the compiler is already in a unspeakable state.
> >
> > The C and C++ front-end, for example, uses a global pretty-printer
> > object that is initialized in toplev.c:general_init(). I have no idea
> > whether toplev.c is included in gnat1 or not. If yes, then maybe you
> > might consider using the global_dc object.
>
> Ah, ok, that makes sense. This is a revision of the previous patch
> that reuses the global global_dc->printer pretty_printer rather than
> construct a local one. I was originally following the examples set
> by tree-mudflap.c:mf_varname_tree and c-pretty-print.c:print_c_tree
> which both call pp_construct to create local pretty_printers guarded
> by a static variable. But your comments about internal_error using
> a pre-constructed pretty-printer (such as reusing global_dc's) during
> fatal error processing makes a lot of sense.
>
> The following patch has been tested on i686-pc-linux-gnu with a "make",
> including Ada, and regression tested with a "make check-gnat" and
> confirming in acats.log that error messages in the gnat bug boxes
> are correctly formatted.
>
> Ok for mainline (Gaby and Richard K)?
Ping!
Gaby ok'ed this patch, some Ada folks still need to speak.
Richard (going over patches applied to SUSE gcc).
>
>
>
> 2005-05-15 Roger Sayle <roger@eyesopen.com>
>
> * misc.c (internal_error_function): Don't use vsprintf to format
> the error message text, instead use pp_format_text and the new
> pretty printer APIs. This allows handling of %qs, %w, etc.
>
>
> Index: misc.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/ada/misc.c,v
> retrieving revision 1.101
> diff -c -3 -p -r1.101 misc.c
> *** misc.c 23 Apr 2005 21:28:09 -0000 1.101
> --- misc.c 16 May 2005 02:00:48 -0000
> *************** gnat_post_options (const char **pfilenam
> *** 365,376 ****
> static void
> internal_error_function (const char *msgid, va_list *ap)
> {
> ! char buffer[1000]; /* Assume this is big enough. */
> char *p;
> String_Template temp;
> Fat_Pointer fp;
>
> ! vsprintf (buffer, msgid, *ap);
>
> /* Go up to the first newline. */
> for (p = buffer; *p; p++)
> --- 365,387 ----
> static void
> internal_error_function (const char *msgid, va_list *ap)
> {
> ! text_info tinfo;
> ! char *buffer;
> char *p;
> String_Template temp;
> Fat_Pointer fp;
>
> ! /* Reset the pretty-printer. */
> ! pp_clear_output_area (global_dc->printer);
> !
> ! /* Format the message into the pretty-printer. */
> ! tinfo.format_spec = msgid;
> ! tinfo.args_ptr = ap;
> ! tinfo.err_no = errno;
> ! pp_format_text (global_dc->printer, &tinfo);
> !
> ! /* Extract a (writable) pointer to the formatted text. */
> ! buffer = (char*) pp_formatted_text (global_dc->printer);
>
> /* Go up to the first newline. */
> for (p = buffer; *p; p++)
> *************** internal_error_function (const char *msg
> *** 380,387 ****
> break;
> }
>
> ! temp.Low_Bound = 1, temp.High_Bound = strlen (buffer);
> ! fp.Array = buffer, fp.Bounds = &temp;
>
> Current_Error_Node = error_gnat_node;
> Compiler_Abort (fp, -1);
> --- 391,400 ----
> break;
> }
>
> ! temp.Low_Bound = 1;
> ! temp.High_Bound = p - buffer;
> ! fp.Bounds = &temp;
> ! fp.Array = buffer;
>
> Current_Error_Node = error_gnat_node;
> Compiler_Abort (fp, -1);
>
>
> Roger
> --
>
>