OSDN Git Service

gcc:
[pf3gnuchains/gcc-fork.git] / gcc / fortran / options.c
index 16e9079..e653ac9 100644 (file)
@@ -1,5 +1,5 @@
 /* Parse and display command line options.
-   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
    Free Software Foundation, Inc.
    Contributed by Andy Vaught
 
@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-inline.h"
 #include "gfortran.h"
 #include "target.h"
+#include "cpp.h"
 
 gfc_option_t gfc_option;
 
@@ -42,29 +43,28 @@ 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_STD_F2003 | GFC_STD_F2008 | 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
-gfc_init_options (unsigned int argc ATTRIBUTE_UNUSED,
-                 const char **argv ATTRIBUTE_UNUSED)
+gfc_init_options (unsigned int argc, const char **argv)
 {
   gfc_source_file = NULL;
   gfc_option.module_dir = NULL;
   gfc_option.source_form = FORM_UNKNOWN;
   gfc_option.fixed_line_length = 72;
   gfc_option.free_line_length = 132;
-  gfc_option.max_continue_fixed = 19;
-  gfc_option.max_continue_free = 39;
+  gfc_option.max_continue_fixed = 255;
+  gfc_option.max_continue_free = 255;
   gfc_option.max_identifier_length = GFC_MAX_SYMBOL_LEN;
   gfc_option.max_subrecord_length = 0;
   gfc_option.convert = GFC_CONVERT_NATIVE;
   gfc_option.record_marker = 0;
-  gfc_option.verbose = 0;
+  gfc_option.dump_parse_tree = 0;
 
   gfc_option.warn_aliasing = 0;
   gfc_option.warn_ampersand = 0;
@@ -128,6 +128,9 @@ gfc_init_options (unsigned int argc ATTRIBUTE_UNUSED,
   /* -fshort-enums can be default on some targets.  */
   gfc_option.fshort_enums = targetm.default_short_enums ();
 
+  /* Initialize cpp-related options.  */
+  gfc_cpp_init_options(argc, argv);
+
   return CL_Fortran;
 }
 
@@ -155,6 +158,9 @@ form_from_filename (const char *filename)
     ".f03", FORM_FREE}
     ,
     {
+    ".f08", FORM_FREE}
+    ,
+    {
     ".f", FORM_FIXED}
     ,
     {
@@ -351,6 +357,15 @@ gfc_post_options (const char **pfilename)
   if (gfc_option.flag_all_intrinsics)
     gfc_option.warn_nonstd_intrinsics = 0;
 
+  gfc_cpp_post_options ();
+
+/* FIXME: return gfc_cpp_preprocess_only ();
+
+   The return value of this function indicates whether the
+   backend needs to be initialized. On -E, we don't need
+   the backend. However, if we return 'true' here, an
+   ICE occurs. Initializing the backend doesn't hurt much,
+   hence, for now we can live with it as is.  */
   return false;
 }
 
@@ -388,16 +403,7 @@ gfc_handle_module_path_options (const char *arg)
 {
 
   if (gfc_option.module_dir != NULL)
-    {
-      gfc_status ("gfortran: Only one -M option allowed\n");
-      exit (3);
-    }
-
-  if (arg == NULL)
-    {
-      gfc_status ("gfortran: Directory required after -M\n");
-      exit (3);
-    }
+    gfc_fatal_error ("gfortran: Only one -J option allowed");
 
   gfc_option.module_dir = (char *) gfc_getmem (strlen (arg) + 2);
   strcpy (gfc_option.module_dir, arg);
@@ -458,6 +464,9 @@ gfc_handle_option (size_t scode, const char *arg, int value)
   if (code == N_OPTS)
     return 1;
 
+  if (gfc_cpp_handle_option (scode, arg, value) == 1)
+    return 1;
+
   switch (code)
     {
     default:
@@ -492,6 +501,10 @@ gfc_handle_option (size_t scode, const char *arg, int value)
       gfc_option.warn_line_truncation = value;
       break;
 
+    case OPT_Wreturn_type:
+      warn_return_type = value;
+      break;
+
     case OPT_Wsurprising:
       gfc_option.warn_surprising = value;
       break;
@@ -557,7 +570,7 @@ gfc_handle_option (size_t scode, const char *arg, int value)
       break;
 
     case OPT_fdump_parse_tree:
-      gfc_option.verbose = value;
+      gfc_option.dump_parse_tree = value;
       break;
 
     case OPT_ffixed_form:
@@ -694,7 +707,7 @@ gfc_handle_option (size_t scode, const char *arg, int value)
       else
        gfc_fatal_error ("Unrecognized option to -finit-real: %s",
                         arg);
-      break;      
+      break;
 
     case OPT_finit_integer_:
       gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
@@ -717,14 +730,13 @@ gfc_handle_option (size_t scode, const char *arg, int value)
       break;
 
     case OPT_J:
-    case OPT_M:
       gfc_handle_module_path_options (arg);
       break;
-    
+
     case OPT_fsign_zero:
       gfc_option.flag_sign_zero = value;
       break;
-    
+
     case OPT_ffpe_trap_:
       gfc_handle_fpe_trap_option (arg);
       break;
@@ -732,6 +744,8 @@ gfc_handle_option (size_t scode, const char *arg, int value)
     case OPT_std_f95:
       gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95 | GFC_STD_F77;
       gfc_option.warn_std = GFC_STD_F95_OBS;
+      gfc_option.max_continue_fixed = 19;
+      gfc_option.max_continue_free = 39;
       gfc_option.max_identifier_length = 31;
       gfc_option.warn_ampersand = 1;
       gfc_option.warn_tabs = 0;
@@ -741,8 +755,15 @@ gfc_handle_option (size_t scode, const char *arg, int value)
       gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77 
        | GFC_STD_F2003 | GFC_STD_F95;
       gfc_option.warn_std = GFC_STD_F95_OBS;
-      gfc_option.max_continue_fixed = 255;
-      gfc_option.max_continue_free = 255;
+      gfc_option.max_identifier_length = 63;
+      gfc_option.warn_ampersand = 1;
+      gfc_option.warn_tabs = 0;
+      break;
+
+    case OPT_std_f2008:
+      gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77 
+       | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008;
+      gfc_option.warn_std = GFC_STD_F95_OBS;
       gfc_option.max_identifier_length = 63;
       gfc_option.warn_ampersand = 1;
       gfc_option.warn_tabs = 0;