Suppress warning with -Wno-overwrite-recursive.
authorMark Eggleston <mark.eggleston@codethink.com>
Wed, 30 Oct 2019 08:37:29 +0000 (08:37 +0000)
committerMark Eggleston <markeggleston@gcc.gnu.org>
Wed, 30 Oct 2019 08:37:29 +0000 (08:37 +0000)
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

gcc/fortran/ChangeLog
gcc/fortran/invoke.texi
gcc/fortran/lang.opt
gcc/fortran/options.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/no_overwrite_recursive_1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/no_overwrite_recursive_2.f90 [new file with mode: 0644]

index e77a3a4..0e8de4b 100644 (file)
@@ -1,3 +1,11 @@
+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>
 
        PR fortran/91863
index fa60eff..1d5cec1 100644 (file)
@@ -149,10 +149,11 @@ and warnings}.
 -Wc-binding-type -Wcharacter-truncation -Wconversion @gol
 -Wdo-subscript -Wfunction-elimination -Wimplicit-interface @gol
 -Wimplicit-procedure -Wintrinsic-shadow -Wuse-without-only @gol
--Wintrinsics-std -Wline-truncation -Wno-align-commons -Wno-tabs @gol
--Wreal-q-constant -Wsurprising -Wunderflow -Wunused-parameter @gol
--Wrealloc-lhs -Wrealloc-lhs-all -Wfrontend-loop-interchange @gol
--Wtarget-lifetime -fmax-errors=@var{n} -fsyntax-only -pedantic @gol
+-Wintrinsics-std -Wline-truncation -Wno-align-commons @gol
+-Wno-overwrite-recursive -Wno-tabs -Wreal-q-constant -Wsurprising @gol
+-Wunderflow -Wunused-parameter -Wrealloc-lhs -Wrealloc-lhs-all @gol
+-Wfrontend-loop-interchange -Wtarget-lifetime -fmax-errors=@var{n} @gol
+-fsyntax-only -pedantic @gol
 -pedantic-errors @gol
 }
 
@@ -989,7 +990,7 @@ nor has been declared as @code{EXTERNAL}.
 @opindex @code{Winteger-division}
 @cindex warnings, integer division
 @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.
 
 @item -Wintrinsics-std
@@ -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
 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
 @opindex @code{Wreal-q-constant}
 @cindex warnings, @code{q} exponent-letter
index 2cfc76d..35b1206 100644 (file)
@@ -289,6 +289,10 @@ Wopenmp-simd
 Fortran
 ; Documented in C
 
+Woverwrite-recursive
+Fortran Warning Var(warn_overwrite_recursive) Init(1)
+Warn that -fno-automatic may break recursion.
+
 Wpedantic
 Fortran
 ; Documented in common.opt
index 771c10e..c875ec1 100644 (file)
@@ -409,7 +409,8 @@ gfc_post_options (const char **pfilename)
     gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-fmax-stack-var-size=%d%>",
                     flag_max_stack_var_size);
   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)
     gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%> implied by "
                     "%<-fopenmp%>");
index 1c478fe..519952f 100644 (file)
@@ -1,3 +1,8 @@
+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>
 
        * g++.dg/other/ptrmem8.C: Test locations too.
diff --git a/gcc/testsuite/gfortran.dg/no_overwrite_recursive_1.f90 b/gcc/testsuite/gfortran.dg/no_overwrite_recursive_1.f90
new file mode 100644 (file)
index 0000000..f12c4b8
--- /dev/null
@@ -0,0 +1,11 @@
+! { 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 } 
diff --git a/gcc/testsuite/gfortran.dg/no_overwrite_recursive_2.f90 b/gcc/testsuite/gfortran.dg/no_overwrite_recursive_2.f90
new file mode 100644 (file)
index 0000000..0944537
--- /dev/null
@@ -0,0 +1,10 @@
+! { 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
+