OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / c-opts.c
index 951118c..589b05b 100644 (file)
@@ -1,5 +1,5 @@
 /* C/ObjC/C++ command line option handling.
-   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
+   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
    Free Software Foundation, Inc.
    Contributed by Neil Booth.
 
@@ -33,7 +33,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostic.h"
 #include "intl.h"
 #include "cppdefault.h"
-#include "c-incpath.h"
+#include "incpath.h"
 #include "debug.h"             /* For debug_hooks.  */
 #include "opts.h"
 #include "options.h"
@@ -54,7 +54,7 @@ along with GCC; see the file COPYING3.  If not see
 #endif
 
 /* CPP's options.  */
-static cpp_options *cpp_opts;
+cpp_options *cpp_opts;
 
 /* Input filename.  */
 static const char *this_input_filename;
@@ -72,9 +72,6 @@ static bool deps_seen;
 /* If -v seen.  */
 static bool verbose;
 
-/* If -lang-fortran seen.  */
-bool lang_fortran = false;
-
 /* Dependency output file.  */
 static const char *deps_file;
 
@@ -249,15 +246,6 @@ c_common_init_options (unsigned int argc, const char **argv)
            result |= CL_C | CL_ObjC | CL_CXX | CL_ObjCXX;
            break;
          }
-
-#ifdef CL_Fortran
-      for (i = 1; i < argc; i++)
-       if (! strcmp (argv[i], "-lang-fortran"))
-       {
-           result |= CL_Fortran;
-           break;
-       }
-#endif
     }
 
   return result;
@@ -288,10 +276,6 @@ c_common_handle_option (size_t scode, const char *arg, int value)
            result = 0;
          break;
        }
-#ifdef CL_Fortran
-      if (lang_fortran && (cl_options[code].flags & (CL_Fortran)))
-       break;
-#endif
       result = 0;
       break;
 
@@ -337,7 +321,7 @@ c_common_handle_option (size_t scode, const char *arg, int value)
            error ("-I- specified twice");
          quote_chain_split = true;
          split_quote_chain ();
-         inform ("obsolete option -I- used, please use -iquote instead");
+         inform (input_location, "obsolete option -I- used, please use -iquote instead");
        }
       break;
 
@@ -392,7 +376,7 @@ c_common_handle_option (size_t scode, const char *arg, int value)
       break;
 
     case OPT_Wall:
-      set_Wunused (value);
+      warn_unused = value;
       set_Wformat (value);
       set_Wimplicit (value);
       warn_char_subscripts = value;
@@ -401,10 +385,13 @@ c_common_handle_option (size_t scode, const char *arg, int value)
       warn_return_type = value;
       warn_sequence_point = value;     /* Was C only.  */
       warn_switch = value;
-      set_Wstrict_aliasing (value);
+      if (warn_strict_aliasing == -1)
+       set_Wstrict_aliasing (value);
       warn_address = value;
-      warn_strict_overflow = value;
+      if (warn_strict_overflow == -1)
+       warn_strict_overflow = value;
       warn_array_bounds = value;
+      warn_volatile_register_var = value;
 
       /* Only warn about unknown pragmas that are not in system
         headers.  */
@@ -417,9 +404,12 @@ c_common_handle_option (size_t scode, const char *arg, int value)
        warn_uninitialized = (value ? 2 : 0);
 
       if (!c_dialect_cxx ())
-       /* We set this to 2 here, but 1 in -Wmain, so -ffreestanding
-          can turn it off only if it's not explicit.  */
-       warn_main = value * 2;
+       {
+         /* We set this to 2 here, but 1 in -Wmain, so -ffreestanding
+            can turn it off only if it's not explicit.  */
+         if (warn_main == -1)
+           warn_main = (value ? 2 : 0);
+       }
       else
        {
          /* C++-specific warnings.  */
@@ -436,6 +426,10 @@ c_common_handle_option (size_t scode, const char *arg, int value)
        warn_pointer_sign = 1;
       break;
 
+    case OPT_Wbuiltin_macro_redefined:
+      cpp_opts->warn_builtin_macro_redefined = value;
+      break;
+
     case OPT_Wcomment:
     case OPT_Wcomments:
       cpp_opts->warn_comments = value;
@@ -480,13 +474,6 @@ c_common_handle_option (size_t scode, const char *arg, int value)
       cpp_opts->warn_invalid_pch = value;
       break;
 
-    case OPT_Wmain:
-      if (value)
-       warn_main = 1;
-      else
-       warn_main = -1;
-      break;
-
     case OPT_Wmissing_include_dirs:
       cpp_opts->warn_missing_include_dirs = value;
       break;
@@ -628,9 +615,6 @@ c_common_handle_option (size_t scode, const char *arg, int value)
     case OPT_fhosted:
       flag_hosted = value;
       flag_no_builtin = !value;
-      /* warn_main will be 2 if set by -Wall, 1 if set by -Wmain */
-      if (!value && warn_main == 2)
-       warn_main = 0;
       break;
 
     case OPT_fshort_double:
@@ -888,10 +872,6 @@ c_common_handle_option (size_t scode, const char *arg, int value)
       cpp_opts->dollars_in_ident = false;
       break;
 
-    case OPT_lang_fortran:
-      lang_fortran = true;
-      break;
-
     case OPT_lang_objc:
       cpp_opts->objc = 1;
       break;
@@ -924,6 +904,8 @@ c_common_handle_option (size_t scode, const char *arg, int value)
        warn_pointer_sign = 1;
       if (warn_overlength_strings == -1)
        warn_overlength_strings = 1;
+      if (warn_main == -1)
+       warn_main = 2;
       break;
 
     case OPT_print_objc_runtime_info:
@@ -1035,14 +1017,6 @@ c_common_post_options (const char **pfilename)
   C_COMMON_OVERRIDE_OPTIONS;
 #endif
 
-  flag_inline_trees = 1;
-
-  /* Use tree inlining.  */
-  if (!flag_no_inline)
-    flag_no_inline = 1;
-  if (flag_inline_functions)
-    flag_inline_trees = 2;
-
   /* By default we use C99 inline semantics in GNU99 or C99 mode.  C99
      inline semantics are not supported in GNU89 or C89 mode.  */
   if (flag_gnu89_inline == -1)
@@ -1050,11 +1024,6 @@ c_common_post_options (const char **pfilename)
   else if (!flag_gnu89_inline && !flag_isoc99)
     error ("-fno-gnu89-inline is only supported in GNU99 or C99 mode");
 
-  /* If we are given more than one input file, we must use
-     unit-at-a-time mode.  */
-  if (num_in_fnames > 1)
-    flag_unit_at_a_time = 1;
-
   /* Default to ObjC sjlj exception handling if NeXT runtime.  */
   if (flag_objc_sjlj_exceptions < 0)
     flag_objc_sjlj_exceptions = flag_next_runtime;
@@ -1090,28 +1059,25 @@ c_common_post_options (const char **pfilename)
   if (warn_pointer_sign == -1)
     warn_pointer_sign = 0;
 
+  if (warn_strict_aliasing == -1)
+    warn_strict_aliasing = 0;
+  if (warn_strict_overflow == -1)
+    warn_strict_overflow = 0;
+
   /* -Woverlength-strings is off by default, but is enabled by -pedantic.
      It is never enabled in C++, as the minimum limit is not normative
      in that standard.  */
   if (warn_overlength_strings == -1 || c_dialect_cxx ())
     warn_overlength_strings = 0;
 
-  /* Adjust various flags for C++ based on command-line settings.  */
-  if (c_dialect_cxx ())
-    {
-      if (!flag_permissive)
-       {
-         flag_pedantic_errors = 1;
-         cpp_opts->pedantic_errors = 1;
-       }
-      if (!flag_no_inline)
-       {
-         flag_inline_trees = 1;
-         flag_no_inline = 1;
-       }
-      if (flag_inline_functions)
-       flag_inline_trees = 2;
-    } 
+  /* Wmain is enabled by default in C++ but not in C.  */
+  /* Wmain is disabled by default for -ffreestanding (!flag_hosted),
+     even if -Wall was given (warn_main will be 2 if set by -Wall, 1
+     if set by -Wmain).  */
+  if (warn_main == -1)
+    warn_main = (c_dialect_cxx () && flag_hosted) ? 1 : 0;
+  else if (warn_main == 2)
+    warn_main = flag_hosted ? 1 : 0;
 
   /* In C, -Wconversion enables -Wsign-conversion (unless disabled
      through -Wno-sign-conversion). While in C++,
@@ -1224,6 +1190,9 @@ c_common_init (void)
   if (version_flag)
     c_common_print_pch_checksum (stderr);
 
+  /* Has to wait until now so that cpplib has its hash table.  */
+  init_pragma ();
+
   if (flag_preprocess_only)
     {
       finish_options ();
@@ -1231,9 +1200,6 @@ c_common_init (void)
       return false;
     }
 
-  /* Has to wait until now so that cpplib has its hash table.  */
-  init_pragma ();
-
   return true;
 }
 
@@ -1424,6 +1390,8 @@ sanitize_cpp_opts (void)
       flag_dump_includes = 0;
       flag_no_line_commands = 1;
     }
+  else if (cpp_opts->deps.missing_files)
+    error ("-MG may only be used with -M or -MM");
 
   cpp_opts->unsigned_char = !flag_signed_char;
   cpp_opts->stdc_0_in_system_headers = STDC_0_IN_SYSTEM_HEADERS;
@@ -1665,6 +1633,7 @@ handle_OPT_d (const char *arg)
       case 'M':                        /* Dump macros only.  */
       case 'N':                        /* Dump names.  */
       case 'D':                        /* Dump definitions.  */
+      case 'U':                        /* Dump used macros.  */
        flag_dump_macros = c;
        break;