* [PATCH, Fortran] Correctly set -fd-lines-as-comments with -fdec
@ 2017-07-31 17:08 Fritz Reese
2017-08-01 15:11 ` Thomas Koenig
0 siblings, 1 reply; 3+ messages in thread
From: Fritz Reese @ 2017-07-31 17:08 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 830 bytes --]
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.
[-- Attachment #2: dec_d_lines.patch --]
[-- Type: text/x-patch, Size: 2778 bytes --]
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH, Fortran] Correctly set -fd-lines-as-comments with -fdec
2017-07-31 17:08 [PATCH, Fortran] Correctly set -fd-lines-as-comments with -fdec Fritz Reese
@ 2017-08-01 15:11 ` Thomas Koenig
2017-08-10 14:10 ` Fritz Reese
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Koenig @ 2017-08-01 15:11 UTC (permalink / raw)
To: Fritz Reese, fortran, gcc-patches
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH, Fortran] Correctly set -fd-lines-as-comments with -fdec
2017-08-01 15:11 ` Thomas Koenig
@ 2017-08-10 14:10 ` Fritz Reese
0 siblings, 0 replies; 3+ messages in thread
From: Fritz Reese @ 2017-08-10 14:10 UTC (permalink / raw)
To: Thomas Koenig; +Cc: fortran, gcc-patches
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-10 14:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-31 17:08 [PATCH, Fortran] Correctly set -fd-lines-as-comments with -fdec Fritz Reese
2017-08-01 15:11 ` Thomas Koenig
2017-08-10 14:10 ` Fritz Reese
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).