Commit 91c4891a by Mark Eggleston Committed by Mark Eggleston

Suppress warning with -Wno-overwrite-recursive.

The use of -fno-automatic with -frecursive results in a warning implying
that recursion will not work. If all relevant local variable have the
automatic attribute explicitly declared recursion does work and the warning
is redundant.

From-SVN: r277602
parent 87f94429
2019-10-30 Mark Eggleston <mark.eggleston@codethink.com>
* invoke.texi: Add -Wno-overwrite-recursive to list of options. Add
description of -Wno-overwrite-recursive. Fix typo in description
of -Winteger-division.
* lang.opt: Add option -Woverwrite-recursive initialised as on.
* option.c (gfc_post_options): Output warning only if it is enabled.
2019-10-28 Tobias Burnus <tobias@codesourcery.com> 2019-10-28 Tobias Burnus <tobias@codesourcery.com>
PR fortran/91863 PR fortran/91863
......
...@@ -149,10 +149,11 @@ and warnings}. ...@@ -149,10 +149,11 @@ and warnings}.
-Wc-binding-type -Wcharacter-truncation -Wconversion @gol -Wc-binding-type -Wcharacter-truncation -Wconversion @gol
-Wdo-subscript -Wfunction-elimination -Wimplicit-interface @gol -Wdo-subscript -Wfunction-elimination -Wimplicit-interface @gol
-Wimplicit-procedure -Wintrinsic-shadow -Wuse-without-only @gol -Wimplicit-procedure -Wintrinsic-shadow -Wuse-without-only @gol
-Wintrinsics-std -Wline-truncation -Wno-align-commons -Wno-tabs @gol -Wintrinsics-std -Wline-truncation -Wno-align-commons @gol
-Wreal-q-constant -Wsurprising -Wunderflow -Wunused-parameter @gol -Wno-overwrite-recursive -Wno-tabs -Wreal-q-constant -Wsurprising @gol
-Wrealloc-lhs -Wrealloc-lhs-all -Wfrontend-loop-interchange @gol -Wunderflow -Wunused-parameter -Wrealloc-lhs -Wrealloc-lhs-all @gol
-Wtarget-lifetime -fmax-errors=@var{n} -fsyntax-only -pedantic @gol -Wfrontend-loop-interchange -Wtarget-lifetime -fmax-errors=@var{n} @gol
-fsyntax-only -pedantic @gol
-pedantic-errors @gol -pedantic-errors @gol
} }
...@@ -989,7 +990,7 @@ nor has been declared as @code{EXTERNAL}. ...@@ -989,7 +990,7 @@ nor has been declared as @code{EXTERNAL}.
@opindex @code{Winteger-division} @opindex @code{Winteger-division}
@cindex warnings, integer division @cindex warnings, integer division
@cindex warnings, division of integers @cindex warnings, division of integers
Warn if a constant integer division truncates it result. Warn if a constant integer division truncates its result.
As an example, 3/5 evaluates to 0. As an example, 3/5 evaluates to 0.
@item -Wintrinsics-std @item -Wintrinsics-std
...@@ -1002,6 +1003,15 @@ it as @code{EXTERNAL} procedure because of this. @option{-fall-intrinsics} can ...@@ -1002,6 +1003,15 @@ it as @code{EXTERNAL} procedure because of this. @option{-fall-intrinsics} can
be used to never trigger this behavior and always link to the intrinsic be used to never trigger this behavior and always link to the intrinsic
regardless of the selected standard. regardless of the selected standard.
@item -Wno-overwrite-recursive
@opindex @code{Woverwrite-recursive}
@cindex warnings, overwrite recursive
Do not warn when @option{-fno-automatic} is used with @option{-frecursive}. Recursion
will be broken if the relevant local variables do not have the attribute
@code{AUTOMATIC} explicitly declared. This option can be used to suppress the warning
when it is known that recursion is not broken. Useful for build environments that use
@option{-Werror}.
@item -Wreal-q-constant @item -Wreal-q-constant
@opindex @code{Wreal-q-constant} @opindex @code{Wreal-q-constant}
@cindex warnings, @code{q} exponent-letter @cindex warnings, @code{q} exponent-letter
......
...@@ -289,6 +289,10 @@ Wopenmp-simd ...@@ -289,6 +289,10 @@ Wopenmp-simd
Fortran Fortran
; Documented in C ; Documented in C
Woverwrite-recursive
Fortran Warning Var(warn_overwrite_recursive) Init(1)
Warn that -fno-automatic may break recursion.
Wpedantic Wpedantic
Fortran Fortran
; Documented in common.opt ; Documented in common.opt
......
...@@ -409,7 +409,8 @@ gfc_post_options (const char **pfilename) ...@@ -409,7 +409,8 @@ gfc_post_options (const char **pfilename)
gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-fmax-stack-var-size=%d%>", gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-fmax-stack-var-size=%d%>",
flag_max_stack_var_size); flag_max_stack_var_size);
else if (!flag_automatic && flag_recursive) else if (!flag_automatic && flag_recursive)
gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%>"); gfc_warning_now (OPT_Woverwrite_recursive, "Flag %<-fno-automatic%> "
"overwrites %<-frecursive%>");
else if (!flag_automatic && flag_openmp) else if (!flag_automatic && flag_openmp)
gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%> implied by " gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%> implied by "
"%<-fopenmp%>"); "%<-fopenmp%>");
......
2019-10-30 Mark Eggleston <mark.eggleston@codethink.com>
* gfortran.dg/no_overwrite_recursive_1.f90: New test.
* gfortran.dg/no_overwrite_recursive_2.f90: New test.
2019-10-29 Paolo Carlini <paolo.carlini@oracle.com> 2019-10-29 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/other/ptrmem8.C: Test locations too. * g++.dg/other/ptrmem8.C: Test locations too.
......
! { dg-do compile }
! { dg-options "-fno-automatic -frecursive" }
!
! Test case contributed by Mark Eggleston <mark.eggleston@codethink.com>
!
program test
! do nothing
end program
! { dg-warning "Flag '-fno-automatic' overwrites '-frecursive'" "warning" { target *-*-* } 0 }
! { dg-do compile }
! { dg-options "-fno-automatic -frecursive -Wno-overwrite-recursive" }
!
! Test case contributed by Mark Eggleston <mark.eggleston@codethink.com>
!
program test
! do nothing
end program
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment