[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-fortran
Subject:    Re: [Patch, Fortran] convert almost all {warning,error}_now to common diagnostic
From:       Tobias Burnus <burnus () net-b ! de>
Date:       2014-11-26 19:26:22
Message-ID: 5476295E.6070202 () net-b ! de
[Download RAW message or body]

Hi Manuel,

Manuel López-Ibáñez wrote:
> I think the changes to the common diagnostics part could be as simple as:
Good – that's simpler than I had feared.

> However, I'm less familiar with the Fortran buffering mechanism.

I am not sure you find someone who really is. At least I also have 
troubles – but most of the time it works as expected.

An implementation criterion would be that it doesn't regress, except 
that changes which do make sense (are better or equivalent) are still fine.

It doesn't have to be completely identical.

> So far, I understood that:
>
> * gfc uses two gfc_error_buf (error_buffer, warning_buffer) and
> pointer *cur_error_buffer; to switch between them. These are
> equivalent to pretty-printer output_buffer, thus my idea is to create
> a gfc_pretty_printer that contains three output_buffer (two for
> buffering and another for the _now variants).
>
> * There seems to be a global buffer_flag that controls when to buffer.
> However, each gfc_error_buf has a variable "flag", that is also
> checked sometimes. Unfortunately, nothing in gfc_error_buf has
> comments, so I have no idea how these flags are supposed to interact.
> It would be great if a Fortran person could explain it in detail.

Well gfc_error_buf's "flag" seems to be 1 if there is a buffered warning 
– and it is set to 0 if either the warning has been printed or dropped 
(e.g. via gfc_clear_error()). Thus, when 
gfc_error_check()/gfc_warning_check() is called, the buffer can be 
printed ("fputs (warning_buffer.message, stderr);").

The only reason that "warning_buffer.message" isn't directly used seems 
to be that that way the memory allocation for the buffer can be reused.

The buffering itself seems to be only controlled by "buffer_flag".

> * I am not sure how to handle the error/warnings counts. The Fortran
> code seems to not care about how many errors or warnings are given
> when buffering, only whether there was any error at all. Is that
> right? It also seems to not care about -fmax-errors (similarly
> -Wfatal-errors will only take care after flushing, thus potentially
> many errors can be given before stopping). Is this correct? Not having
> to handle those would simplify a first version a lot.

Looking at the code, newer errors even seem to always override previous 
ones:

The gfc_{error,warning}{,_now_1} functions all have code like:
   error_buffer.index = 0;
which effectively clears the error buffer by overriding it with the new 
string.

Thus, one has only to take care of incrementing the count when actually 
printing the buffer.

> * I assume that ICEs and other such fatal_errors are never buffered.
> For normal errors converted to fatal by Wfatal-errors, I just need to
> be careful in the buffered variants, that is disable it before going
> through the common machinery and re-enable it after returning from it.
> (This is a note to myself).

Tobias
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic