/* 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.
#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
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);
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
warn_unknown_pragmas = value;
warn_uninitialized = value;
+ warn_maybe_uninitialized = value;
if (!c_dialect_cxx ())
{
warn_sign_compare = value;
warn_reorder = value;
warn_cxx0x_compat = value;
+ warn_delnonvdtor = value;
+ warn_narrowing = value;
}
cpp_opts->warn_trigraphs = 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;
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;
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;
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)
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:
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:
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:
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)
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)
{
{
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;
}
&& 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;
}
if (flag_preprocess_only)
{
- finish_options ();
+ c_finish_options ();
preprocess_file (parse_in);
return false;
}
i = 0;
for (;;)
{
- finish_options ();
+ c_finish_options ();
pch_init ();
push_file_scope ();
c_parse_file ();
{
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;
/* 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)
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). */
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;
}
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