OSDN Git Service

2012-01-18 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / c-family / c-opts.c
index 7d12859..f2a7971 100644 (file)
@@ -1,5 +1,5 @@
 /* C/ObjC/C++ command line option handling.
-   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
    Contributed by Neil Booth.
 
@@ -36,7 +36,12 @@ along with GCC; see the file COPYING3.  If not see
 #include "opts.h"
 #include "options.h"
 #include "mkdeps.h"
-#include "target.h"            /* For gcc_targetcm.  */
+#include "c-target.h"
+#include "tm.h"                        /* For BYTES_BIG_ENDIAN,
+                                  DOLLARS_IN_IDENTIFIERS,
+                                  STDC_0_IN_SYSTEM_HEADERS,
+                                  TARGET_FLT_EVAL_METHOD_NON_DEFAULT and
+                                  TARGET_OPTF.  */
 #include "tm_p.h"              /* For C_COMMON_OVERRIDE_OPTIONS.  */
 
 #ifndef DOLLARS_IN_IDENTIFIERS
@@ -105,10 +110,10 @@ static size_t include_cursor;
 
 static void handle_OPT_d (const char *);
 static void set_std_cxx98 (int);
-static void set_std_cxx0x (int);
+static void set_std_cxx11 (int);
 static void set_std_c89 (int, int);
 static void set_std_c99 (int);
-static void set_std_c1x (int);
+static void set_std_c11 (int);
 static void check_deps_environment_vars (void);
 static void handle_deferred_opts (void);
 static void sanitize_cpp_opts (void);
@@ -116,7 +121,7 @@ static void add_prefixed_path (const char *, size_t);
 static void push_command_line_include (void);
 static void cb_file_change (cpp_reader *, const struct line_map *);
 static void cb_dir_change (cpp_reader *, const char *);
-static void finish_options (void);
+static void c_finish_options (void);
 
 #ifndef STDC_0_IN_SYSTEM_HEADERS
 #define STDC_0_IN_SYSTEM_HEADERS 0
@@ -379,6 +384,7 @@ c_common_handle_option (size_t scode, const char *arg, int value,
       warn_unknown_pragmas = value;
 
       warn_uninitialized = value;
+      warn_maybe_uninitialized = value;
 
       if (!c_dialect_cxx ())
        {
@@ -399,6 +405,8 @@ c_common_handle_option (size_t scode, const char *arg, int value,
           warn_sign_compare = value;
          warn_reorder = value;
           warn_cxx0x_compat = value;
+          warn_delnonvdtor = value;
+         warn_narrowing = value;
        }
 
       cpp_opts->warn_trigraphs = value;
@@ -429,6 +437,10 @@ c_common_handle_option (size_t scode, const char *arg, int value,
       cpp_opts->warn_cxx_operator_names = value;
       break;
 
+    case OPT_Wc__0x_compat:
+      warn_narrowing = value;
+      break;
+
     case OPT_Wdeprecated:
       cpp_opts->cpp_warn_deprecated = value;
       break;
@@ -437,10 +449,6 @@ c_common_handle_option (size_t scode, const char *arg, int value,
       cpp_opts->warn_endif_labels = value;
       break;
 
-    case OPT_Werror:
-      global_dc->warning_as_error_requested = value;
-      break;
-
     case OPT_Wformat:
       set_Wformat (value);
       break;
@@ -592,14 +600,6 @@ c_common_handle_option (size_t scode, const char *arg, int value,
       cpp_opts->extended_identifiers = value;
       break;
 
-    case OPT_fgnu_runtime:
-      flag_next_runtime = !value;
-      break;
-
-    case OPT_fnext_runtime:
-      flag_next_runtime = value;
-      break;
-
     case OPT_foperator_names:
       cpp_opts->operator_names = value;
       break;
@@ -621,6 +621,22 @@ c_common_handle_option (size_t scode, const char *arg, int value,
       cpp_opts->preprocessed = value;
       break;
 
+    case OPT_fdebug_cpp:
+      cpp_opts->debug = 1;
+      break;
+
+    case OPT_ftrack_macro_expansion:
+      if (value)
+       value = 2;
+      /* Fall Through.  */
+
+    case OPT_ftrack_macro_expansion_:
+      if (arg && *arg != '\0')
+       cpp_opts->track_macro_expansion = value;
+      else
+       cpp_opts->track_macro_expansion = 2;
+      break;
+
     case OPT_frepo:
       flag_use_repository = value;
       if (value)
@@ -654,16 +670,16 @@ c_common_handle_option (size_t scode, const char *arg, int value,
       break;
 
     case OPT_femit_struct_debug_baseonly:
-      set_struct_debug_option (&global_options, "base");
+      set_struct_debug_option (&global_options, loc, "base");
       break;
 
     case OPT_femit_struct_debug_reduced:
-      set_struct_debug_option (&global_options,
+      set_struct_debug_option (&global_options, loc,
                               "dir:ord:sys,dir:gen:any,ind:base");
       break;
 
     case OPT_femit_struct_debug_detailed_:
-      set_struct_debug_option (&global_options, arg);
+      set_struct_debug_option (&global_options, loc, arg);
       break;
 
     case OPT_idirafter:
@@ -752,10 +768,10 @@ c_common_handle_option (size_t scode, const char *arg, int value,
        set_std_cxx98 (code == OPT_std_c__98 /* ISO */);
       break;
 
-    case OPT_std_c__0x:
-    case OPT_std_gnu__0x:
+    case OPT_std_c__11:
+    case OPT_std_gnu__11:
       if (!preprocessing_asm_p)
-       set_std_cxx0x (code == OPT_std_c__0x /* ISO */);
+       set_std_cxx11 (code == OPT_std_c__11 /* ISO */);
       break;
 
     case OPT_std_c90:
@@ -779,14 +795,14 @@ c_common_handle_option (size_t scode, const char *arg, int value,
        set_std_c99 (false /* ISO */);
       break;
 
-    case OPT_std_c1x:
+    case OPT_std_c11:
       if (!preprocessing_asm_p)
-       set_std_c1x (true /* ISO */);
+       set_std_c11 (true /* ISO */);
       break;
 
-    case OPT_std_gnu1x:
+    case OPT_std_gnu11:
       if (!preprocessing_asm_p)
-       set_std_c1x (false /* ISO */);
+       set_std_c11 (false /* ISO */);
       break;
 
     case OPT_trigraphs:
@@ -809,6 +825,16 @@ c_common_handle_option (size_t scode, const char *arg, int value,
   return result;
 }
 
+/* Default implementation of TARGET_HANDLE_C_OPTION.  */
+
+bool
+default_handle_c_option (size_t code ATTRIBUTE_UNUSED,
+                        const char *arg ATTRIBUTE_UNUSED,
+                        int value ATTRIBUTE_UNUSED)
+{
+  return false;
+}
+
 /* Post-switch processing.  */
 bool
 c_common_post_options (const char **pfilename)
@@ -964,10 +990,17 @@ c_common_post_options (const char **pfilename)
   if (warn_implicit_function_declaration == -1)
     warn_implicit_function_declaration = flag_isoc99;
 
-  /* If we're allowing C++0x constructs, don't warn about C++0x
-     compatibility problems.  */
   if (cxx_dialect == cxx0x)
-    warn_cxx0x_compat = 0;
+    {
+      /* If we're allowing C++0x constructs, don't warn about C++98
+        identifiers which are keywords in C++0x.  */
+      warn_cxx0x_compat = 0;
+
+      if (warn_narrowing == -1)
+       warn_narrowing = 1;
+    }
+  else if (warn_narrowing == -1)
+    warn_narrowing = 0;
 
   if (flag_preprocess_only)
     {
@@ -995,6 +1028,12 @@ c_common_post_options (const char **pfilename)
     {
       init_c_lex ();
 
+      /* When writing a PCH file, avoid reading some other PCH file,
+        because the default address space slot then can't be used
+        for the output PCH file.  */
+      if (pch_file)
+       c_common_no_more_pch ();
+
       /* Yuk.  WTF is this?  I do know ObjC relies on it somewhere.  */
       input_location = UNKNOWN_LOCATION;
     }
@@ -1019,6 +1058,13 @@ c_common_post_options (const char **pfilename)
       && flag_preprocess_only && !flag_no_line_commands)
     pp_dir_change (parse_in, get_src_pwd ());
 
+  /* Disable LTO output when outputting a precompiled header.  */
+  if (pch_file && flag_lto)
+    {
+      flag_lto = 0;
+      flag_generate_lto = 0;
+    }
+
   return flag_preprocess_only;
 }
 
@@ -1047,7 +1093,7 @@ c_common_init (void)
 
   if (flag_preprocess_only)
     {
-      finish_options ();
+      c_finish_options ();
       preprocess_file (parse_in);
       return false;
     }
@@ -1065,7 +1111,7 @@ c_common_parse_file (void)
   i = 0;
   for (;;)
     {
-      finish_options ();
+      c_finish_options ();
       pch_init ();
       push_file_scope ();
       c_parse_file ();
@@ -1131,12 +1177,12 @@ check_deps_environment_vars (void)
 {
   char *spec;
 
-  GET_ENVIRONMENT (spec, "DEPENDENCIES_OUTPUT");
+  spec = getenv ("DEPENDENCIES_OUTPUT");
   if (spec)
     cpp_opts->deps.style = DEPS_USER;
   else
     {
-      GET_ENVIRONMENT (spec, "SUNPRO_DEPENDENCIES");
+      spec = getenv ("SUNPRO_DEPENDENCIES");
       if (spec)
        {
          cpp_opts->deps.style = DEPS_SYSTEM;
@@ -1277,18 +1323,23 @@ add_prefixed_path (const char *suffix, size_t chain)
 
 /* Handle -D, -U, -A, -imacros, and the first -include.  */
 static void
-finish_options (void)
+c_finish_options (void)
 {
   if (!cpp_opts->preprocessed)
     {
       size_t i;
 
-      cb_file_change (parse_in,
-                     linemap_add (line_table, LC_RENAME, 0,
-                                  _("<built-in>"), 0));
+      {
+       /* Make sure all of the builtins about to be declared have
+         BUILTINS_LOCATION has their source_location.  */
+       source_location builtins_loc = BUILTINS_LOCATION;
+       cpp_force_token_locations (parse_in, &builtins_loc);
 
-      cpp_init_builtins (parse_in, flag_hosted);
-      c_cpp_builtins (parse_in);
+       cpp_init_builtins (parse_in, flag_hosted);
+       c_cpp_builtins (parse_in);
+
+       cpp_stop_forcing_token_locations (parse_in);
+      }
 
       /* We're about to send user input to cpplib, so make it warn for
         things that we previously (when we sent it internal definitions)
@@ -1417,7 +1468,7 @@ set_std_c89 (int c94, int iso)
   flag_no_nonansi_builtin = iso;
   flag_isoc94 = c94;
   flag_isoc99 = 0;
-  flag_isoc1x = 0;
+  flag_isoc11 = 0;
 }
 
 /* Set the C 99 standard (without GNU extensions if ISO).  */
@@ -1428,20 +1479,20 @@ set_std_c99 (int iso)
   flag_no_asm = iso;
   flag_no_nonansi_builtin = iso;
   flag_iso = iso;
-  flag_isoc1x = 0;
+  flag_isoc11 = 0;
   flag_isoc99 = 1;
   flag_isoc94 = 1;
 }
 
-/* Set the C 1X standard draft (without GNU extensions if ISO).  */
+/* Set the C 11 standard (without GNU extensions if ISO).  */
 static void
-set_std_c1x (int iso)
+set_std_c11 (int iso)
 {
-  cpp_set_lang (parse_in, iso ? CLK_STDC1X: CLK_GNUC1X);
+  cpp_set_lang (parse_in, iso ? CLK_STDC11: CLK_GNUC11);
   flag_no_asm = iso;
   flag_no_nonansi_builtin = iso;
   flag_iso = iso;
-  flag_isoc1x = 1;
+  flag_isoc11 = 1;
   flag_isoc99 = 1;
   flag_isoc94 = 1;
 }
@@ -1457,15 +1508,18 @@ set_std_cxx98 (int iso)
   cxx_dialect = cxx98;
 }
 
-/* Set the C++ 0x working draft "standard" (without GNU extensions if ISO).  */
+/* Set the C++ 2011 standard (without GNU extensions if ISO).  */
 static void
-set_std_cxx0x (int iso)
+set_std_cxx11 (int iso)
 {
-  cpp_set_lang (parse_in, iso ? CLK_CXX0X: CLK_GNUCXX0X);
+  cpp_set_lang (parse_in, iso ? CLK_CXX11: CLK_GNUCXX11);
   flag_no_gnu_keywords = iso;
   flag_no_nonansi_builtin = iso;
   flag_iso = iso;
-  cxx_dialect = cxx0x;
+  /* C++11 includes the C99 standard library.  */
+  flag_isoc94 = 1;
+  flag_isoc99 = 1;
+  cxx_dialect = cxx11;
 }
 
 /* Args to -d specify what to dump.  Silently ignore