Blame SOURCES/gcc7-fortran-fpad-source.patch

726b1e
2018-11-23  Jakub Jelinek  <jakub@redhat.com>
726b1e
726b1e
	* lang.opt (fpad-source): New option.
726b1e
	* scanner.c (load_line): Don't pad fixed form lines if
726b1e
	!flag_pad_source.
726b1e
	* invoke.texi (-fno-pad-source): Document.
726b1e
726b1e
--- gcc/fortran/invoke.texi
726b1e
+++ gcc/fortran/invoke.texi
726b1e
@@ -119,7 +119,7 @@ by type.  Explanations are in the follow
726b1e
 -fdec -fdec-structure -fdec-intrinsic-ints -fdec-static -fdec-math @gol
726b1e
 -fdec-include -fdefault-double-8 -fdefault-integer-8 @gol
726b1e
 -fdefault-real-8 -fdollar-ok -ffixed-line-length-@var{n} @gol
726b1e
--ffixed-line-length-none -ffree-form -ffree-line-length-@var{n} @gol
726b1e
+-ffixed-line-length-none -fpad-source -ffree-form -ffree-line-length-@var{n} @gol
726b1e
 -ffree-line-length-none -fimplicit-none -finteger-4-integer-8 @gol
726b1e
 -fmax-identifier-length -fmodule-private -ffixed-form -fno-range-check @gol
726b1e
 -fopenacc -fopenmp -freal-4-real-10 -freal-4-real-16 -freal-4-real-8 @gol
726b1e
@@ -321,8 +321,9 @@ declared as @code{PUBLIC}.
726b1e
 @opindex @code{ffixed-line-length-}@var{n}
726b1e
 @cindex file format, fixed
726b1e
 Set column after which characters are ignored in typical fixed-form
726b1e
-lines in the source file, and through which spaces are assumed (as
726b1e
-if padded to that length) after the ends of short fixed-form lines.
726b1e
+lines in the source file, and, unless @code{-fno-pad-source}, through which
726b1e
+spaces are assumed (as if padded to that length) after the ends of short
726b1e
+fixed-form lines.
726b1e
 
726b1e
 Popular values for @var{n} include 72 (the
726b1e
 standard and the default), 80 (card image), and 132 (corresponding
726b1e
@@ -333,6 +334,15 @@ to them to fill out the line.
726b1e
 @option{-ffixed-line-length-0} means the same thing as
726b1e
 @option{-ffixed-line-length-none}.
726b1e
 
726b1e
+@item -fno-pad-source
726b1e
+@opindex @code{fpad-source}
726b1e
+By default fixed-form lines have spaces assumed (as if padded to that length)
726b1e
+after the ends of short fixed-form lines.  This is not done either if
726b1e
+@option{-ffixed-line-length-0}, @option{-ffixed-line-length-none} or
726b1e
+if @option{-fno-pad-source} option is used.  With any of those options
726b1e
+continued character constants never have implicit spaces appended
726b1e
+to them to fill out the line.
726b1e
+
726b1e
 @item -ffree-line-length-@var{n}
726b1e
 @opindex @code{ffree-line-length-}@var{n}
726b1e
 @cindex file format, free
726b1e
--- gcc/fortran/lang.opt
726b1e
+++ gcc/fortran/lang.opt
726b1e
@@ -536,6 +536,10 @@ ffixed-line-length-
726b1e
 Fortran RejectNegative Joined UInteger Var(flag_fixed_line_length) Init(72)
726b1e
 -ffixed-line-length-<n>	Use n as character line width in fixed mode.
726b1e
 
726b1e
+fpad-source
726b1e
+Fortran Var(flag_pad_source) Init(1)
726b1e
+Pad shorter fixed form lines to line width with spaces.
726b1e
+
726b1e
 ffpe-trap=
726b1e
 Fortran RejectNegative JoinedOrMissing
726b1e
 -ffpe-trap=[...]	Stop on following floating point exceptions.
726b1e
--- gcc/fortran/scanner.c
726b1e
+++ gcc/fortran/scanner.c
726b1e
@@ -1924,6 +1924,7 @@ next_char:
726b1e
   /* Pad lines to the selected line length in fixed form.  */
726b1e
   if (gfc_current_form == FORM_FIXED
726b1e
       && flag_fixed_line_length != 0
726b1e
+      && flag_pad_source
726b1e
       && !preprocessor_flag
726b1e
       && c != EOF)
726b1e
     {
726b1e
--- /dev/null
726b1e
+++ gcc/testsuite/gfortran.dg/pad_source_1.f
726b1e
@@ -0,0 +1,8 @@
726b1e
+c { dg-do run }
726b1e
+c { dg-skip-if "non-standard options" { *-*-* } { "-ffixed-line-length*" "-f*pad-source" } }
726b1e
+      character(80) a
726b1e
+      a = 'abc
726b1e
+     +def'
726b1e
+      if (a(:61) .ne. 'abc') stop 1
726b1e
+      if (a(62:) .ne. 'def') stop 2
726b1e
+      end
726b1e
--- /dev/null
726b1e
+++ gcc/testsuite/gfortran.dg/pad_source_2.f
726b1e
@@ -0,0 +1,9 @@
726b1e
+c { dg-do run }
726b1e
+c { dg-skip-if "non-standard options" { *-*-* } { "-ffixed-line-length*" } }
726b1e
+c { dg-options "-fpad-source" }
726b1e
+      character(80) a
726b1e
+      a = 'abc
726b1e
+     +def'
726b1e
+      if (a(:61) .ne. 'abc') stop 1
726b1e
+      if (a(62:) .ne. 'def') stop 2
726b1e
+      end
726b1e
--- /dev/null
726b1e
+++ gcc/testsuite/gfortran.dg/pad_source_3.f
726b1e
@@ -0,0 +1,8 @@
726b1e
+c { dg-do run }
726b1e
+c { dg-skip-if "non-standard options" { *-*-* } { "-ffixed-line-length*" } }
726b1e
+c { dg-options "-fno-pad-source" }
726b1e
+      character(80) a
726b1e
+      a = 'abc
726b1e
+     +def'
726b1e
+      if (a .ne. 'abcdef') stop 1
726b1e
+      end
726b1e
--- /dev/null
726b1e
+++ gcc/testsuite/gfortran.dg/pad_source_4.f
726b1e
@@ -0,0 +1,7 @@
726b1e
+c { dg-do run }
726b1e
+c { dg-options "-ffixed-line-length-none" }
726b1e
+      character(80) a
726b1e
+      a = 'abc
726b1e
+     +def'
726b1e
+      if (a .ne. 'abcdef') stop 1
726b1e
+      end
726b1e
--- /dev/null
726b1e
+++ gcc/testsuite/gfortran.dg/pad_source_5.f
726b1e
@@ -0,0 +1,7 @@
726b1e
+c { dg-do run }
726b1e
+c { dg-options "-ffixed-line-length-0" }
726b1e
+      character(80) a
726b1e
+      a = 'abc
726b1e
+     +def'
726b1e
+      if (a .ne. 'abcdef') stop 1
726b1e
+      end