/* C/ObjC/C++ command line option handling.
- Copyright (C) 2002-2019 Free Software Foundation, Inc.
+ Copyright (C) 2002-2020 Free Software Foundation, Inc.
Contributed by Neil Booth.
This file is part of GCC.
static void set_std_cxx11 (int);
static void set_std_cxx14 (int);
static void set_std_cxx17 (int);
-static void set_std_cxx2a (int);
+static void set_std_cxx20 (int);
static void set_std_c89 (int, int);
static void set_std_c99 (int);
static void set_std_c11 (int);
{
char *saved_prefix = pp_take_prefix (context->printer);
pp_set_prefix (context->printer, NULL);
+ pp_newline (context->printer);
diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind);
/* By default print macro expansion contexts in the diagnostic
finalizer -- for tokens resulting from macro expansion. */
}
}
- /* Set C++ standard to C++14 if not specified on the command line. */
+ /* Set C++ standard to C++17 if not specified on the command line. */
if (c_dialect_cxx ())
- set_std_cxx14 (/*ISO*/false);
+ set_std_cxx17 (/*ISO*/false);
global_dc->colorize_source_p = true;
}
set_std_cxx17 (code == OPT_std_c__17 /* ISO */);
break;
- case OPT_std_c__2a:
- case OPT_std_gnu__2a:
+ case OPT_std_c__20:
+ case OPT_std_gnu__20:
if (!preprocessing_asm_p)
- set_std_cxx2a (code == OPT_std_c__2a /* ISO */);
+ set_std_cxx20 (code == OPT_std_c__20 /* ISO */);
break;
case OPT_std_c90:
else
flag_permitted_flt_eval_methods = PERMITTED_FLT_EVAL_METHODS_C11;
+ /* C2X Annex F does not permit certain built-in functions to raise
+ "inexact". */
+ if (flag_isoc2x)
+ SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+ flag_fp_int_builtin_inexact, 0);
+
/* 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)
/* If -ffreestanding, -fno-hosted or -fno-builtin then disable
pattern recognition. */
- if (!global_options_set.x_flag_tree_loop_distribute_patterns
- && flag_no_builtin)
- flag_tree_loop_distribute_patterns = 0;
+ if (flag_no_builtin)
+ SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+ flag_tree_loop_distribute_patterns, 0);
/* -Woverlength-strings is off by default, but is enabled by -Wpedantic.
It is never enabled in C++, as the minimum limit is not normative
if (warn_implicit_int == -1)
warn_implicit_int = flag_isoc99;
+ /* -Wold-style-definition is enabled by default for C2X. */
+ if (warn_old_style_definition == -1)
+ warn_old_style_definition = flag_isoc2x;
+
/* -Wshift-overflow is enabled by default in C99 and C++11 modes. */
if (warn_shift_overflow == -1)
warn_shift_overflow = cxx_dialect >= cxx11 || flag_isoc99;
&& (cxx_dialect >= cxx11 || flag_isoc99));
/* -Wregister is enabled by default in C++17. */
- if (!global_options_set.x_warn_register)
- warn_register = cxx_dialect >= cxx17;
+ SET_OPTION_IF_UNSET (&global_options, &global_options_set, warn_register,
+ cxx_dialect >= cxx17);
/* -Wcomma-subscript is enabled by default in C++20. */
- if (!global_options_set.x_warn_comma_subscript)
- warn_comma_subscript = (cxx_dialect >= cxx2a && warn_deprecated);
+ SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+ warn_comma_subscript,
+ cxx_dialect >= cxx20 && warn_deprecated);
/* -Wvolatile is enabled by default in C++20. */
- if (!global_options_set.x_warn_volatile)
- warn_volatile = (cxx_dialect >= cxx2a && warn_deprecated);
+ SET_OPTION_IF_UNSET (&global_options, &global_options_set, warn_volatile,
+ cxx_dialect >= cxx20 && warn_deprecated);
/* Declone C++ 'structors if -Os. */
if (flag_declone_ctor_dtor == -1)
/* Change flag_abi_version to be the actual current ABI level, for the
benefit of c_cpp_builtins, and to make comparison simpler. */
- const int latest_abi_version = 13;
+ const int latest_abi_version = 14;
/* Generate compatibility aliases for ABI v11 (7.1) by default. */
const int abi_compat_default = 11;
/* By default, enable the new inheriting constructor semantics along with ABI
11. New and old should coexist fine, but it is a change in what
artificial symbols are generated. */
- if (!global_options_set.x_flag_new_inheriting_ctors)
- flag_new_inheriting_ctors = abi_version_at_least (11);
+ SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+ flag_new_inheriting_ctors,
+ abi_version_at_least (11));
/* For GCC 7, only enable DR150 resolution by default if -std=c++17. */
- if (!global_options_set.x_flag_new_ttp)
- flag_new_ttp = (cxx_dialect >= cxx17);
+ SET_OPTION_IF_UNSET (&global_options, &global_options_set, flag_new_ttp,
+ cxx_dialect >= cxx17);
+
+ /* C++11 guarantees forward progress. */
+ SET_OPTION_IF_UNSET (&global_options, &global_options_set, flag_finite_loops,
+ optimize >= 2 && cxx_dialect >= cxx11);
if (cxx_dialect >= cxx11)
{
if (flag_sized_deallocation == -1)
flag_sized_deallocation = (cxx_dialect >= cxx14);
- /* char8_t support is new in C++2A. */
+ /* char8_t support is new in C++20. */
if (flag_char8_t == -1)
- flag_char8_t = (cxx_dialect >= cxx2a);
+ flag_char8_t = (cxx_dialect >= cxx20);
if (flag_extern_tls_init)
{
if (warn_return_type == -1 && c_dialect_cxx ())
warn_return_type = 1;
+ /* C++20 is the final version of concepts. We still use -fconcepts
+ to know when concepts are enabled. Note that -fconcepts-ts can
+ be used to include additional features, although modified to
+ work with the standard. */
+ if (cxx_dialect >= cxx20 || flag_concepts_ts)
+ flag_concepts = 1;
+ else if (flag_concepts)
+ /* For -std=c++17 -fconcepts, imply -fconcepts-ts. */
+ flag_concepts_ts = 1;
+
if (num_in_fnames > 1)
error ("too many filenames given; type %<%s %s%> for usage",
progname, "--help");
input_location = UNKNOWN_LOCATION;
*pfilename = this_input_filename
- = cpp_read_main_file (parse_in, in_fnames[0]);
+ = cpp_read_main_file (parse_in, in_fnames[0],
+ /* We'll inject preamble pieces if this is
+ not preprocessed. */
+ !cpp_opts->preprocessed);
+
/* Don't do any compilation or preprocessing if there is no input file. */
if (this_input_filename == NULL)
{
if (!deps_seen)
return;
- mkdeps *deps = cpp_get_deps (parse_in);
-
- for (size_t i = 0; i < deferred_count; i++)
- {
- struct deferred_opt *opt = &deferred_opts[i];
+ if (mkdeps *deps = cpp_get_deps (parse_in))
+ for (unsigned i = 0; i < deferred_count; i++)
+ {
+ struct deferred_opt *opt = &deferred_opts[i];
- if (opt->code == OPT_MT || opt->code == OPT_MQ)
- deps_add_target (deps, opt->arg, opt->code == OPT_MQ);
- }
+ if (opt->code == OPT_MT || opt->code == OPT_MQ)
+ deps_add_target (deps, opt->arg, opt->code == OPT_MQ);
+ }
}
/* These settings are appropriate for GCC, but not necessarily so for
= linemap_check_ordinary (linemap_add (line_table, LC_RENAME, 0,
_("<built-in>"), 0));
cb_file_change (parse_in, bltin_map);
+ linemap_line_start (line_table, 0, 1);
/* Make sure all of the builtins about to be declared have
BUILTINS_LOCATION has their location_t. */
= linemap_check_ordinary (linemap_add (line_table, LC_RENAME, 0,
_("<command-line>"), 0));
cb_file_change (parse_in, cmd_map);
+ linemap_line_start (line_table, 0, 1);
/* All command line defines must have the same location. */
- cpp_force_token_locations (parse_in, cmd_map->start_location);
+ cpp_force_token_locations (parse_in, line_table->highest_line);
for (size_t i = 0; i < deferred_count; i++)
{
struct deferred_opt *opt = &deferred_opts[i];
lang_hooks.name = "GNU C++17";
}
-/* Set the C++ 202a draft standard (without GNU extensions if ISO). */
+/* Set the C++ 2020 standard (without GNU extensions if ISO). */
static void
-set_std_cxx2a (int iso)
+set_std_cxx20 (int iso)
{
- cpp_set_lang (parse_in, iso ? CLK_CXX2A: CLK_GNUCXX2A);
+ cpp_set_lang (parse_in, iso ? CLK_CXX20: CLK_GNUCXX20);
flag_no_gnu_keywords = iso;
flag_no_nonansi_builtin = iso;
flag_iso = iso;
flag_isoc94 = 1;
flag_isoc99 = 1;
flag_isoc11 = 1;
- cxx_dialect = cxx2a;
- lang_hooks.name = "GNU C++17"; /* Pretend C++17 until standardization. */
+ /* C++20 includes coroutines. */
+ flag_coroutines = true;
+ cxx_dialect = cxx20;
+ lang_hooks.name = "GNU C++20";
}
/* Args to -d specify what to dump. Silently ignore