re PR fortran/64522 (Free-form source code: -Wline-truncation is no longer enabled...
authorTobias Burnus <burnus@net-b.de>
Sat, 10 Jan 2015 15:49:37 +0000 (16:49 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Sat, 10 Jan 2015 15:49:37 +0000 (16:49 +0100)
2015-01-10  Tobias Burnus  <burnus@net-b.de>

        PR fortran/64522
        * invoke.texi (Wline-truncation): Document new behaviour.
        * lang.opt (Wline-truncation): Add Init(-1).
        * options.c (gfc_post_options): If -Wline-truncation is unset,
        enable it for free-form source files; for the latter, also use
        -Werror=line-truncation, unless -Wno-error has been specified.

2015-01-10  Tobias Burnus  <burnus@net-b.de>

        PR fortran/64522
        * gfortran.dg/line_length_5.f90: Change dg-warning to dg-error
        and add dg-excess-errors.
        * gfortran.dg/line_length_6.f90: New.
        * gfortran.dg/line_length_7.f90: New.
        * gfortran.dg/line_length_8.f90: New.
        * gfortran.dg/line_length_9.f90: New.
        * gfortran.dg/line_length_10.f90: New.
        * gfortran.dg/line_length_11.f90: New.

From-SVN: r219424

13 files changed:
gcc/fortran/ChangeLog
gcc/fortran/invoke.texi
gcc/fortran/lang.opt
gcc/fortran/options.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/line_length_10.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/line_length_11.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/line_length_4.f90
gcc/testsuite/gfortran.dg/line_length_5.f90
gcc/testsuite/gfortran.dg/line_length_6.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/line_length_7.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/line_length_8.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/line_length_9.f90 [new file with mode: 0644]

index 141bc486d7e8078657cd23163cec6467d5dbaa2c..c10a1dba024cf8a87b2c54ddd6c29e245b0a40d8 100644 (file)
@@ -1,3 +1,12 @@
+2015-01-10  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/64522
+       * invoke.texi (Wline-truncation): Document new behaviour.
+       * lang.opt (Wline-truncation): Add Init(-1).
+       * options.c (gfc_post_options): If -Wline-truncation is unset,
+       enable it for free-form source files; for the latter, also use
+       -Werror=line-truncation, unless -Wno-error has been specified.
+
 2015-01-09  Michael Collison  <michael.collison@linaro.org>
 
        * convert.c: Include hash-set.h, machmode.h, vec.h, double-int.h,
index 4cf36e8690ed0869950bb8c1ef9c2c61b507b4a1..39bc479c2cb55867d5b99d3ed7dc6f0a661a90e8 100644 (file)
@@ -790,7 +790,9 @@ Warn when a character assignment will truncate the assigned string.
 @opindex @code{Wline-truncation}
 @cindex warnings, line truncation
 Warn when a source code line will be truncated.  This option is
-implied by @option{-Wall}.
+implied by @option{-Wall}.  For free-form source code, the default is
+@option{-Werror=line-truncation} such that truncations are reported as
+error.
 
 @item -Wconversion
 @opindex @code{Wconversion}
index c4ebbe71ade3a6f6c5faeccbf627df70da6b2909..530ec979e6563a327f657c63e08b56418f61d6f0 100644 (file)
@@ -250,7 +250,7 @@ Fortran Warning Var(warn_implicit_procedure)
 Warn about called procedures not explicitly declared
 
 Wline-truncation
-Fortran Warning Var(warn_line_truncation) LangEnabledBy(Fortran,Wall)
+Fortran Warning Var(warn_line_truncation) LangEnabledBy(Fortran,Wall) Init(-1)
 Warn about truncated source lines
 
 Wintrinsics-std
index a356f538eaae96fdbbfc4089b324aaff225da860..4bae04e13523e30b8e8405c3ab7b641de8f98649 100644 (file)
@@ -314,7 +314,20 @@ gfc_post_options (const char **pfilename)
                           "in free form");
       else if (gfc_option.flag_d_lines == 1)
        gfc_warning_now ("%<-fd-lines-as-code%> has no effect in free form");
+
+      if (warn_line_truncation == -1)
+         warn_line_truncation = 1;
+
+      /* Enable -Werror=line-truncation when -Werror and -Wno-error have
+        not been set.  */
+      if (warn_line_truncation && !global_options_set.x_warnings_are_errors
+         && (global_dc->classify_diagnostic[OPT_Wline_truncation] ==
+             DK_UNSPECIFIED))
+       diagnostic_classify_diagnostic (global_dc, OPT_Wline_truncation,
+                                       DK_ERROR, UNKNOWN_LOCATION);
     }
+  else if (warn_line_truncation == -1)
+    warn_line_truncation = 0;
 
   /* If -pedantic, warn about the use of GNU extensions.  */
   if (pedantic && (gfc_option.allow_std & GFC_STD_GNU) != 0)
index 496ba92faf714522e9b36ad75f114e8b79a3ec5f..44b44e3e129e9c9753bbb6f6b9990d8cea324f03 100644 (file)
@@ -1,3 +1,15 @@
+2015-01-10  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/64522
+       * gfortran.dg/line_length_5.f90: Change dg-warning to dg-error
+       and add dg-excess-errors.
+       * gfortran.dg/line_length_6.f90: New.
+       * gfortran.dg/line_length_7.f90: New.
+       * gfortran.dg/line_length_8.f90: New.
+       * gfortran.dg/line_length_9.f90: New.
+       * gfortran.dg/line_length_10.f90: New.
+       * gfortran.dg/line_length_11.f90: New.
+
 2015-01-09  David Malcolm  <dmalcolm@redhat.com>
 
        * jit.dg/test-threads.c (struct testcase): Move declaration
diff --git a/gcc/testsuite/gfortran.dg/line_length_10.f90 b/gcc/testsuite/gfortran.dg/line_length_10.f90
new file mode 100644 (file)
index 0000000..390e9a1
--- /dev/null
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! { dg-options "-Wno-line-truncation" }
+!
+! By default, for free-form source code: Error out
+! But due to the explicit -Wno-line-truncation, compile w/o warning
+!
+      print *, 1                                                                                                                                          + 2
+      end
diff --git a/gcc/testsuite/gfortran.dg/line_length_11.f90 b/gcc/testsuite/gfortran.dg/line_length_11.f90
new file mode 100644 (file)
index 0000000..67f1e29
--- /dev/null
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! { dg-options "-Wno-all" }
+!
+! By default, for free-form source code: Error out
+! But due to the explicit -Wno-all, compile w/o warning
+!
+      print *, 1                                                                                                                                          + 2
+      end
index 52bba1c874ef3f3dea61d8723399c45be5c1b25d..6e3c76e6f88f2b2086003f708eae36cee97c7a31 100644 (file)
@@ -15,4 +15,5 @@
      end do
    end subroutine foo
   end
-! { dg-warning "Line truncated" " " { target *-*-* } 8 }
+! { dg-error "Line truncated" " " { target *-*-* } 8 }
+! { dg-excess-errors "some warnings being treated as errors" }
index b9c2946ade22317b259528bc1a4b3f8a26d111a6..d7aca12e00452448a65f945a9f48a56b95417528 100644 (file)
@@ -2,5 +2,6 @@
 ! { dg-options "-Wline-truncation" }
 print *, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
 end 
-! { dg-warning "Line truncated" " " { target *-*-* } 3 }
+! { dg-error "Line truncated" " " { target *-*-* } 3 }
 ! { dg-error "Unterminated character constant" " " { target *-*-* } 3 }
+! { dg-excess-errors "some warnings being treated as errors" }
diff --git a/gcc/testsuite/gfortran.dg/line_length_6.f90 b/gcc/testsuite/gfortran.dg/line_length_6.f90
new file mode 100644 (file)
index 0000000..92f3401
--- /dev/null
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! { dg-options "" }
+!
+! By default, for free-form source code: Error out
+!
+      print *, 1                                                                                                                                          + 2 ! { dg-error "Line truncated at .1." }
+      end
+! { dg-excess-errors "some warnings being treated as errors" }
diff --git a/gcc/testsuite/gfortran.dg/line_length_7.f90 b/gcc/testsuite/gfortran.dg/line_length_7.f90
new file mode 100644 (file)
index 0000000..b4ebf49
--- /dev/null
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! { dg-options "-Wno-error" }
+!
+! By default, for free-form source code: Error out
+! But due to -Wno-error, we only expect a warning
+!
+      print *, 1                                                                                                                                          + 2 ! { dg-warning "Line truncated at .1." }
+      end
diff --git a/gcc/testsuite/gfortran.dg/line_length_8.f90 b/gcc/testsuite/gfortran.dg/line_length_8.f90
new file mode 100644 (file)
index 0000000..3f0efaf
--- /dev/null
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! { dg-options "-Wline-truncation" }
+!
+! By default, for free-form source code: Error out
+! Even with -Wline-truncation, we still get an error
+!
+      print *, 1                                                                                                                                          + 2 ! { dg-error "Line truncated at .1." }
+      end
+! { dg-excess-errors "some warnings being treated as errors" }
diff --git a/gcc/testsuite/gfortran.dg/line_length_9.f90 b/gcc/testsuite/gfortran.dg/line_length_9.f90
new file mode 100644 (file)
index 0000000..f338972
--- /dev/null
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! { dg-options "-Wall" }
+!
+! By default, for free-form source code: Error out
+! Even with -Wall, we still get an error
+!
+      print *, 1                                                                                                                                          + 2 ! { dg-error "Line truncated at .1." }
+      end
+! { dg-excess-errors "some warnings being treated as errors" }