This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [PATCH fortran/diagnostics] Move gfc_error (buffered) to common diagnostics
- From: Manuel López-Ibáñez <lopezibanez at gmail dot com>
- To: Dodji Seketeli <dodji at redhat dot com>
- Cc: Tobias Burnus <burnus at net-b dot de>, Gcc Patch List <gcc-patches at gcc dot gnu dot org>, "fortran at gcc dot gnu dot org List" <fortran at gcc dot gnu dot org>
- Date: Wed, 10 Dec 2014 14:17:31 +0100
- Subject: Re: [PATCH fortran/diagnostics] Move gfc_error (buffered) to common diagnostics
- Authentication-results: sourceware.org; auth=none
- References: <CAESRpQAAk9nQub8W7Wv+8gXv5d9ovSxFgQh8QLYkUX7xswW=rg at mail dot gmail dot com> <CAESRpQCo3ycino1GJGympS4ZALHwHQ1+p-vbngBEaZZf8atBLA at mail dot gmail dot com> <87signk6md dot fsf at redhat dot com>
On 10 December 2014 at 13:54, Dodji Seketeli <dodji@redhat.com> wrote:
>> /* Report the number of warnings and errors that occurred to the caller. */
>>
>> @@ -1525,11 +1625,14 @@ gfc_diagnostics_init (void)
>> {
>> diagnostic_starter (global_dc) = gfc_diagnostic_starter;
>> diagnostic_finalizer (global_dc) = gfc_diagnostic_finalizer;
>> diagnostic_format_decoder (global_dc) = gfc_format_decoder;
>> global_dc->caret_char = '^';
>> - new (&pp_warning_buffer) output_buffer ();
>> + pp_warning_buffer = new output_buffer ();
>
> When I look at the code of the destructor the pretty_printer type
> (pretty_printer::~pretty_printer) in gcc/pretty-print.c, I see that the
> memory for the output buffer is de-allocated using XDELETE. So I think
> the memory for the output buffer should be allocated using XNEW and the
> output_buffer type should instantiated using a placement new operator
> that uses that XNEWed allocated memory.
The reason we use this placement-new stuff is precisely the use of
XNEW and XDELETE, since those do not call the cons/des-tructors.
However, a lot of code in GCC is directly using new/delete already. I
don't see any reason to not do so in the pretty-printer/diagnostics
code. In fact, David Malcom recently did a similar change for
tree-pretty-print.c:
https://gcc.gnu.org/ml/gcc-patches/2014-11/msg03213.html
But I agree that using XNEW and placement-new is probably safer for
now. I'll try that and submit a new version.
Cheers,
Manuel.