options.c (set_dec_flags, [...]): Only set flag_d_lines with -fdec when not set by...
authorFritz Reese <fritzoreese@gmail.com>
Thu, 10 Aug 2017 12:36:44 +0000 (12:36 +0000)
committerFritz Reese <foreese@gcc.gnu.org>
Thu, 10 Aug 2017 12:36:44 +0000 (12:36 +0000)
2017-08-10  Fritz Reese <Reese-Fritz@zai.com>

    gcc/fortran/ChangeLog:

* options.c (set_dec_flags, gfc_post_options): Only set flag_d_lines
with -fdec when not set by user.

    gcc/testsuite/ChangeLog:

    gfortran.dg/
* dec_d_lines_1.f, dec_d_lines_2.f: New.

From-SVN: r251024

gcc/fortran/ChangeLog
gcc/fortran/options.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/dec_d_lines_1.f [new file with mode: 0644]
gcc/testsuite/gfortran.dg/dec_d_lines_2.f [new file with mode: 0644]

index 45b16d48b28722e8852eae4ec033ebc4d9bf0890..20fa93f6ec9410f7e8d5c88a1225721016d04a97 100644 (file)
@@ -1,4 +1,9 @@
-2017-08-10  Fritz Reese <Reese-Fritz@zai.com>
+2017-08-10  Fritz Reese <fritzoreese@gmail.com>
+
+       * options.c (set_dec_flags, gfc_post_options): Only set flag_d_lines
+       with -fdec when not set by user.
+
+2017-08-10  Fritz Reese <fritzoreese@gmail.com>
 
        * decl.c (attr_seen): New static variable.
        * decl.c (variable_decl): Match %FILL in STRUCTURE body.
index 283c8354e06e90dd5783b26db64b10ec37ab3926..cd254e932296555f242f953468d0556c3bbf1da2 100644 (file)
@@ -57,9 +57,6 @@ set_dec_flags (int value)
     | GFC_STD_GNU | GFC_STD_LEGACY;
   gfc_option.warn_std &= ~(GFC_STD_LEGACY | GFC_STD_F95_DEL);
 
-  /* Set -fd-lines-as-comments by default.  */
-  if (value && gfc_current_form != FORM_FREE && gfc_option.flag_d_lines == -1)
-    gfc_option.flag_d_lines = 0;
 
   /* Set other DEC compatibility extensions.  */
   flag_dollar_ok |= value;
@@ -339,8 +336,15 @@ gfc_post_options (const char **pfilename)
        diagnostic_classify_diagnostic (global_dc, OPT_Wline_truncation,
                                        DK_ERROR, UNKNOWN_LOCATION);
     }
-  else if (warn_line_truncation == -1)
-    warn_line_truncation = 0;
+  else
+    {
+      /* With -fdec, set -fd-lines-as-comments by default in fixed form.  */
+      if (flag_dec && gfc_option.flag_d_lines == -1)
+       gfc_option.flag_d_lines = 0;
+
+      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 adae3b9bee218ad71f19f2899f84158e16491b14..a1e72369cd34ae4509702c9d21f220a7624da9e1 100644 (file)
@@ -1,4 +1,9 @@
-2017-08-10  Fritz Reese <Reese-Fritz@zai.com>
+2017-08-10  Fritz Reese <fritzoreese@gmail.com>
+
+       * gfortran.dg/dec_d_lines_1.f: New test.
+       * gfortran.dg/dec_d_lines_2.f: New test.
+
+2017-08-10  Fritz Reese <fritzoreese@gmail.com>
 
        * gfortran.dg/dec_structure_18.f90: New test.
        * gfortran.dg/dec_structure_19.f90: New test.
diff --git a/gcc/testsuite/gfortran.dg/dec_d_lines_1.f b/gcc/testsuite/gfortran.dg/dec_d_lines_1.f
new file mode 100644 (file)
index 0000000..2cc7a01
--- /dev/null
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! { dg-options "-ffixed-form -fd-lines-as-code -fdec" }
+!
+! Ensure -fd-lines-as-code is not overridden by -fdec.
+!
+      i = 0
+d     end
+      subroutine s
+D     end
diff --git a/gcc/testsuite/gfortran.dg/dec_d_lines_2.f b/gcc/testsuite/gfortran.dg/dec_d_lines_2.f
new file mode 100644 (file)
index 0000000..31eaf5f
--- /dev/null
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! { dg-options "-ffixed-form -fdec" }
+!
+! Ensure -fd-lines-as-comments is enabled by default with -fdec.
+!
+d This is a comment.
+D This line, too.
+      end