[PATCH, Fortran] Optionally suppress no-automatic overwrites recursive warning - for review

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH, Fortran] Optionally suppress no-automatic overwrites recursive warning - for review

Mark Eggleston
The following warning is produced when -fno-automatic and -frecursive
are used at the same time:

f951: Warning: Flag '-fno-automatic' overwrites '-frecursive'

This is a reasonable warning, however, recursion can be used with the
-fno-automatic flag where recursion is enabled using -frecusive instead
of explicitly using the recursive keyword.

If all relevant subroutines local variables are explicitly declared
automatic then recursion will work and the warning becomes a nuisance
when -Werror is used in the build environment.

This patch allows the warning to be switched off using a new option,
-Woverwrite-recursive, initialised to on.

I don't have a test case for this as I don't know how to test for a
warning that isn't related to a line of code.

It is a very simple patch, can the test case be omitted?

ChangeLog

gcc/fortran

     Mark Eggleston  <[hidden email]>

     * lang.opt: Add option -Woverwrite-recursive initialised as on.
     * option.c (gfc_post_options): Output warning only if it is enabled.

--
https://www.codethink.co.uk/privacy.html


0009-Suppress-warning-with-Wno-overwrite-recursive.patch (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH, Fortran] Optionally suppress no-automatic overwrites recursive warning - for review

Tobias Burnus-3
Hi Mark,

On 9/19/19 3:40 PM, Mark Eggleston wrote:

> The following warning is produced when -fno-automatic and -frecursive
> are used at the same time:
>
> f951: Warning: Flag '-fno-automatic' overwrites '-frecursive'
>
> This patch allows the warning to be switched off using a new option,
> -Woverwrite-recursive, initialised to on.
>
> I don't have a test case for this as I don't know how to test for a
> warning that isn't related to a line of code.

Try:

! { dg-warning "Flag .-fno-automatic. overwrites .-frecursive." "" {
target *-*-* } 0 }

The syntax is { dg-warning "message", "label" {target ...} linenumber },
where linenumber = 0 means it can be on any line.

If the output doesn't match (but I think it does with "Warning:"),
general messages can be caught with "dg-message".


Thanks,

Tobias


Reply | Threaded
Open this post in threaded view
|

Re: [PATCH, Fortran] Optionally suppress no-automatic overwrites recursive warning - for review

Bernhard Reutner-Fischer
On Thu, 19 Sep 2019 17:46:29 +0200
Tobias Burnus <[hidden email]> wrote:

> Hi Mark,
>
> On 9/19/19 3:40 PM, Mark Eggleston wrote:
> > The following warning is produced when -fno-automatic and -frecursive
> > are used at the same time:
> >
> > f951: Warning: Flag '-fno-automatic' overwrites '-frecursive'
> >
> > This patch allows the warning to be switched off using a new option,
> > -Woverwrite-recursive, initialised to on.
> >
> > I don't have a test case for this as I don't know how to test for a
> > warning that isn't related to a line of code.  
>
> Try:
>
> ! { dg-warning "Flag .-fno-automatic. overwrites .-frecursive." "" {
> target *-*-* } 0 }
>
> The syntax is { dg-warning "message", "label" {target ...} linenumber },
> where linenumber = 0 means it can be on any line.
>
> If the output doesn't match (but I think it does with "Warning:"),
> general messages can be caught with "dg-message".

Also:

> @@ -411,7 +411,7 @@ gfc_post_options (const char **pfilename)
>        && flag_max_stack_var_size != 0)
>      gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-fmax-stack-var-size=%d%>",
>       flag_max_stack_var_size);
> -  else if (!flag_automatic && flag_recursive)
> +  else if (!flag_automatic && flag_recursive && warn_overwrite_recursive)
>      gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%>");
>    else if (!flag_automatic && flag_openmp)
>      gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%> implied by "
>

Doesn't look right to me. Do you want
gfc_warning_now (OPT_Woverwrite_recursive, "Flag ...
instead?

thanks,
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH, Fortran] Optionally suppress no-automatic overwrites recursive warning - for review

Bernhard Reutner-Fischer
On Tue, 24 Sep 2019 12:12:04 +0100
Mark Eggleston <[hidden email]> wrote:

> >> @@ -411,7 +411,7 @@ gfc_post_options (const char **pfilename)
> >>         && flag_max_stack_var_size != 0)
> >>       gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-fmax-stack-var-size=%d%>",
> >>       flag_max_stack_var_size);
> >> -  else if (!flag_automatic && flag_recursive)
> >> +  else if (!flag_automatic && flag_recursive && warn_overwrite_recursive)
> >>       gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%>");
> >>     else if (!flag_automatic && flag_openmp)
> >>       gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%> implied by "
> >>
> > Doesn't look right to me. Do you want
> > gfc_warning_now (OPT_Woverwrite_recursive, "Flag ...
> > instead?
> Done.

by "instead" i mean you to leave the if unchanged.

thanks,
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH, Fortran] Optionally suppress no-automatic overwrites recursive warning - for review

Mark Eggleston

On 24/09/2019 14:53, Bernhard Reutner-Fischer wrote:

> On Tue, 24 Sep 2019 12:12:04 +0100
> Mark Eggleston <[hidden email]> wrote:
>
>>>> @@ -411,7 +411,7 @@ gfc_post_options (const char **pfilename)
>>>>          && flag_max_stack_var_size != 0)
>>>>        gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-fmax-stack-var-size=%d%>",
>>>>         flag_max_stack_var_size);
>>>> -  else if (!flag_automatic && flag_recursive)
>>>> +  else if (!flag_automatic && flag_recursive && warn_overwrite_recursive)
>>>>        gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%>");
>>>>      else if (!flag_automatic && flag_openmp)
>>>>        gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%> implied by "
>>>>
>>> Doesn't look right to me. Do you want
>>> gfc_warning_now (OPT_Woverwrite_recursive, "Flag ...
>>> instead?
>> Done.
> by "instead" i mean you to leave the if unchanged.
I didn't realise that's how it worked. That's cleaner. Once fixed OK for
commit?
>
> thanks,
>
--
https://www.codethink.co.uk/privacy.html