diff mbox

[Fortran] Slight cleanup in set_dec_flags

Message ID CAE4aFAkB3iMA=pTcsX1C7eykpeP7CLWMLqyOo8JFA5Hdq73E9w@mail.gmail.com
State New
Headers show

Commit Message

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

Attached is a trivial patch which exists for posterity: currently
set_dec_flags(int value) enables support for legacy standards and
disables warnings for them etc... Unfortunately it does this
irrespective of the int value parameter. Since set_dec_flags(0) is
called on initialization, the legacy standards are enabled even when
-fdec is not specified on the command-line. However, since
set_dec_flags is called *just before* set_default_std_flags() in
gfc_init_options() the standards are correctly reset to defaults. I
believe a guard around setting the legacy standards from set_dec_flags
to ensure they are only set with value != 0 is appropriate for clarity
and correctness.

I plan to commit to trunk soon if there no objections since the patch
is trivial and does not effectively change compiler behavior at
present.

---
Fritz Reese


From 805b4909deb450216c1dc522d834173455baca69 Mon Sep 17 00:00:00 2001
From: Fritz Reese <Reese-Fritz@zai.com>
Date: Mon, 31 Jul 2017 12:58:30 -0400
Subject: [PATCH] Only set legacy std in set_dec_flags when value!=0 for
 posterity

    gcc/fortran/
        * options.c (set_dec_flags): Only set legacy standards when value
        is not zero.
diff mbox

Patch

From 805b4909deb450216c1dc522d834173455baca69 Mon Sep 17 00:00:00 2001
From: Fritz Reese <Reese-Fritz@zai.com>
Date: Mon, 31 Jul 2017 12:58:30 -0400
Subject: [PATCH] Only set legacy std in set_dec_flags when value!=0 for
 posterity

    gcc/fortran/
	* options.c (set_dec_flags): Only set legacy standards when value
	is not zero.
---
 gcc/fortran/options.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index 8cb861bf513..c2f8b8a9398 100644
--- a/gcc/fortran/options.c
+++ b/gcc/fortran/options.c
@@ -52,11 +52,13 @@  set_default_std_flags (void)
 static void
 set_dec_flags (int value)
 {
-  /* Allow legacy code without warnings.  */
-  gfc_option.allow_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL
-    | GFC_STD_GNU | GFC_STD_LEGACY;
-  gfc_option.warn_std &= ~(GFC_STD_LEGACY | GFC_STD_F95_DEL);
-
+  if (value)
+    {
+      /* Allow legacy code without warnings.  */
+      gfc_option.allow_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL
+        | GFC_STD_GNU | GFC_STD_LEGACY;
+      gfc_option.warn_std &= ~(GFC_STD_LEGACY | GFC_STD_F95_DEL);
+    }
 
   /* Set other DEC compatibility extensions.  */
   flag_dollar_ok |= value;
-- 
2.12.2