This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch,fortran] Fixup for options.c


Hello,

The attached patch consolidates the setting of the allow_std and warn_std flags within options.c to one place in the code by creating a new function. This function is then used in the three places where the same code was being duplicated.

This corrects an error of omission on my part for the patch I committed for pr30681 and helps avoid future errors by the consolidation. With this patch, no warnings are given with pr17229.f with -std=gnu.

Regression tested on x86-64_Gnu/Linux.

OK for trunk. Should these fix ups go to the 4.2 branch?

Regards,

Jerry

2007-02-19 Jerry DeLisle <jvdelisle@gcc.gnu.org>

	* options.c (set_default_std_flags): New function to consolidate
	setting the flags.
	(gfc_init_options): Use new function.
	(gfc_handle_option): Use new function.

Index: options.c
===================================================================
--- options.c	(revision 122124)
+++ options.c	(working copy)
@@ -36,6 +36,18 @@ Software Foundation, 51 Franklin Street,
 gfc_option_t gfc_option;
 
 
+/* Set flags that control warnings and errors for different
+   Fortran standards to their default values.  */
+
+static void
+set_default_std_flags (void)
+{
+  gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
+    | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F77 | GFC_STD_GNU
+    | GFC_STD_LEGACY;
+  gfc_option.warn_std = GFC_STD_F95_DEL | GFC_STD_LEGACY;
+}
+
 /* Get ready for options handling.  */
 
 unsigned int
@@ -97,10 +109,7 @@ gfc_init_options (unsigned int argc ATTR
 
   flag_errno_math = 0;
 
-  gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
-    | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F77 | GFC_STD_GNU
-    | GFC_STD_LEGACY;
-  gfc_option.warn_std = GFC_STD_F95_DEL | GFC_STD_LEGACY;
+  set_default_std_flags ();
 
   gfc_option.warn_nonstd_intrinsics = 0;
 
@@ -624,17 +633,11 @@ gfc_handle_option (size_t scode, const c
       break;
 
     case OPT_std_gnu:
-      gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
-	| GFC_STD_F77 | GFC_STD_F95 | GFC_STD_F2003
-	| GFC_STD_GNU | GFC_STD_LEGACY;
-      gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
-	| GFC_STD_LEGACY;
+      set_default_std_flags ();
       break;
 
     case OPT_std_legacy:
-      gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
-	| GFC_STD_F77 | GFC_STD_F95 | GFC_STD_F2003
-	| GFC_STD_GNU | GFC_STD_LEGACY;
+      set_default_std_flags ();
       gfc_option.warn_std = 0;
       break;
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]