lang.opt (fpad-source): New option.
authorJakub Jelinek <jakub@redhat.com>
Fri, 23 Nov 2018 00:11:11 +0000 (01:11 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 23 Nov 2018 00:11:11 +0000 (01:11 +0100)
* lang.opt (fpad-source): New option.
* scanner.c (load_line): Don't pad fixed form lines if
!flag_pad_source.
* invoke.texi (-fno-pad-source): Document.

* gfortran.dg/pad_source_1.f: New test.
* gfortran.dg/pad_source_2.f: New test.
* gfortran.dg/pad_source_3.f: New test.
* gfortran.dg/pad_source_4.f: New test.
* gfortran.dg/pad_source_5.f: New test.

From-SVN: r266397

gcc/fortran/ChangeLog
gcc/fortran/invoke.texi
gcc/fortran/lang.opt
gcc/fortran/scanner.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pad_source_1.f [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pad_source_2.f [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pad_source_3.f [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pad_source_4.f [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pad_source_5.f [new file with mode: 0644]

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