[PATCH] command line macros
https://gcc.gnu.org/ml/gcc-patches/2018-10/msg02062.html * c-opts.c (c_finish_options): Force command line macro location. Refactor to avoid repeating main debug hook. (push_command_line_include): Clarify comment. From-SVN: r265696
This commit is contained in:
parent
22e0527251
commit
ab5324fb68
2 changed files with 38 additions and 40 deletions
|
@ -1,5 +1,9 @@
|
|||
2018-10-31 Nathan Sidwell <nathan@acm.org>
|
||||
|
||||
* c-opts.c (c_finish_options): Force command line macro
|
||||
location. Refactor to avoid repeating main debug hook.
|
||||
(push_command_line_include): Clarify comment.
|
||||
|
||||
* c-opts.c (c_finish_options): Adjust cpp_force_token_locations call.
|
||||
|
||||
2018-10-30 Martin Sebor <msebor@redhat.com>
|
||||
|
|
|
@ -1387,13 +1387,11 @@ c_finish_options (void)
|
|||
{
|
||||
if (!cpp_opts->preprocessed)
|
||||
{
|
||||
size_t i;
|
||||
const line_map_ordinary *bltin_map
|
||||
= linemap_check_ordinary (linemap_add (line_table, LC_RENAME, 0,
|
||||
_("<built-in>"), 0));
|
||||
cb_file_change (parse_in, bltin_map);
|
||||
|
||||
cb_file_change (parse_in,
|
||||
linemap_check_ordinary (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. */
|
||||
cpp_force_token_locations (parse_in, BUILTINS_LOCATION);
|
||||
|
@ -1401,8 +1399,6 @@ c_finish_options (void)
|
|||
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)
|
||||
told it to not warn.
|
||||
|
@ -1414,11 +1410,14 @@ c_finish_options (void)
|
|||
their acceptance on the -std= setting. */
|
||||
cpp_opts->warn_dollars = (cpp_opts->cpp_pedantic && !cpp_opts->c99);
|
||||
|
||||
cb_file_change (parse_in,
|
||||
linemap_check_ordinary (linemap_add (line_table, LC_RENAME, 0,
|
||||
_("<command-line>"), 0)));
|
||||
const line_map_ordinary *cmd_map
|
||||
= linemap_check_ordinary (linemap_add (line_table, LC_RENAME, 0,
|
||||
_("<command-line>"), 0));
|
||||
cb_file_change (parse_in, cmd_map);
|
||||
|
||||
for (i = 0; i < deferred_count; i++)
|
||||
/* All command line defines must have the same location. */
|
||||
cpp_force_token_locations (parse_in, cmd_map->start_location);
|
||||
for (size_t i = 0; i < deferred_count; i++)
|
||||
{
|
||||
struct deferred_opt *opt = &deferred_opts[i];
|
||||
|
||||
|
@ -1435,35 +1434,30 @@ c_finish_options (void)
|
|||
}
|
||||
}
|
||||
|
||||
/* Start the main input file, if the debug writer wants it. */
|
||||
if (debug_hooks->start_end_main_source_file
|
||||
&& !flag_preprocess_only)
|
||||
(*debug_hooks->start_source_file) (0, this_input_filename);
|
||||
|
||||
/* Handle -imacros after -D and -U. */
|
||||
for (i = 0; i < deferred_count; i++)
|
||||
{
|
||||
struct deferred_opt *opt = &deferred_opts[i];
|
||||
|
||||
if (opt->code == OPT_imacros
|
||||
&& cpp_push_include (parse_in, opt->arg))
|
||||
{
|
||||
/* Disable push_command_line_include callback for now. */
|
||||
include_cursor = deferred_count + 1;
|
||||
cpp_scan_nooutput (parse_in);
|
||||
}
|
||||
}
|
||||
cpp_stop_forcing_token_locations (parse_in);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cpp_opts->directives_only)
|
||||
cpp_init_special_builtins (parse_in);
|
||||
else if (cpp_opts->directives_only)
|
||||
cpp_init_special_builtins (parse_in);
|
||||
|
||||
/* Start the main input file, if the debug writer wants it. */
|
||||
if (debug_hooks->start_end_main_source_file
|
||||
&& !flag_preprocess_only)
|
||||
(*debug_hooks->start_source_file) (0, this_input_filename);
|
||||
}
|
||||
/* Start the main input file, if the debug writer wants it. */
|
||||
if (debug_hooks->start_end_main_source_file
|
||||
&& !flag_preprocess_only)
|
||||
(*debug_hooks->start_source_file) (0, this_input_filename);
|
||||
|
||||
if (!cpp_opts->preprocessed)
|
||||
/* Handle -imacros after -D and -U. */
|
||||
for (size_t i = 0; i < deferred_count; i++)
|
||||
{
|
||||
struct deferred_opt *opt = &deferred_opts[i];
|
||||
|
||||
if (opt->code == OPT_imacros
|
||||
&& cpp_push_include (parse_in, opt->arg))
|
||||
{
|
||||
/* Disable push_command_line_include callback for now. */
|
||||
include_cursor = deferred_count + 1;
|
||||
cpp_scan_nooutput (parse_in);
|
||||
}
|
||||
}
|
||||
|
||||
include_cursor = 0;
|
||||
push_command_line_include ();
|
||||
|
@ -1506,7 +1500,7 @@ push_command_line_include (void)
|
|||
include_cursor++;
|
||||
/* -Wunused-macros should only warn about macros defined hereafter. */
|
||||
cpp_opts->warn_unused_macros = cpp_warn_unused_macros;
|
||||
/* Restore the line map from <command line>. */
|
||||
/* Restore the line map back to the main file. */
|
||||
if (!cpp_opts->preprocessed)
|
||||
cpp_change_file (parse_in, LC_RENAME, this_input_filename);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue