diff mbox

[Fortran] Correctly set -fd-lines-as-comments with -fdec

Message ID CAE4aFAnUWRZOgFL-xRn8RC2WwnpBYAevAwNj87=RaGT10hq_4Q@mail.gmail.com
State New
Headers show

Commit Message

Fritz Reese July 31, 2017, 5:07 p.m. UTC
All,

This is a simple patch. The original intent was for -fdec to set
-fd-lines-as-comments by default if flag_d_lines was unspecified by
the user. However, currently flag_d_lines is interrogated in
set_dec_flags(), usually before its final value is determined. The
attached patch fixes this behavior to work as intended.

Any objections for trunk? If not I think it is safe to commit.

---
Fritz Reese

From e2761d73e818a5095bcc130ddbafe27022e25ba6 Mon Sep 17 00:00:00 2001
From: Fritz Reese <Reese-Fritz@zai.com>
Date: Mon, 31 Jul 2017 12:46:10 -0400
Subject: [PATCH] Correctly set -fd-lines-as-comments with -fdec

    gcc/fortran/
        * options.c (set_dec_flags, gfc_post_options): Set flag_d_lines
        with -fdec when not set by user.

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

Comments

Thomas Koenig Aug. 1, 2017, 3:11 p.m. UTC | #1
Hi Fritz,

> This is a simple patch. The original intent was for -fdec to set
> -fd-lines-as-comments by default if flag_d_lines was unspecified by
> the user. However, currently flag_d_lines is interrogated in
> set_dec_flags(), usually before its final value is determined. The
> attached patch fixes this behavior to work as intended.
> 
> Any objections for trunk? If not I think it is safe to commit.

Did you regression-test?  OK for trunk if yes.

Regards

	Thomas
Fritz Reese Aug. 10, 2017, 2:07 p.m. UTC | #2
Yes I did. Committed, thanks.

---
Fritz Reese


On Tue, Aug 1, 2017 at 11:11 AM, Thomas Koenig <tkoenig@netcologne.de> wrote:
> Hi Fritz,
>
>> This is a simple patch. The original intent was for -fdec to set
>> -fd-lines-as-comments by default if flag_d_lines was unspecified by
>> the user. However, currently flag_d_lines is interrogated in
>> set_dec_flags(), usually before its final value is determined. The
>> attached patch fixes this behavior to work as intended.
>>
>> Any objections for trunk? If not I think it is safe to commit.
>
>
> Did you regression-test?  OK for trunk if yes.
>
> Regards
>
>         Thomas
diff mbox

Patch

From e2761d73e818a5095bcc130ddbafe27022e25ba6 Mon Sep 17 00:00:00 2001
From: Fritz Reese <Reese-Fritz@zai.com>
Date: Mon, 31 Jul 2017 12:46:10 -0400
Subject: [PATCH] Don't override -fd-lines-as-code with -fdec.

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

    gcc/testsuite/gfortran.dg/
	* dec_d_lines_1.f, dec_d_lines_2.f: New.
---
 gcc/fortran/options.c                     | 14 +++++++++-----
 gcc/testsuite/gfortran.dg/dec_d_lines_1.f |  9 +++++++++
 gcc/testsuite/gfortran.dg/dec_d_lines_2.f |  8 ++++++++
 3 files changed, 26 insertions(+), 5 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/dec_d_lines_1.f
 create mode 100644 gcc/testsuite/gfortran.dg/dec_d_lines_2.f

diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index 1af76aa81ec..8cb861bf513 100644
--- a/gcc/fortran/options.c
+++ b/gcc/fortran/options.c
@@ -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;
@@ -337,8 +334,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)
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
index 00000000000..2cc7a01daff
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/dec_d_lines_1.f
@@ -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
index 00000000000..31eaf5f2328
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/dec_d_lines_2.f
@@ -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
-- 
2.12.2