From c22027a00ede06e3f53170a82aa5b6af8697ddc4 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Wed, 20 May 2020 11:15:34 -0700 Subject: [PATCH] preprocessor: cleanups in c-common handling * c-common.c (try_to_locate_new_include_insertion_point): Use strcmp to compare filenames. * c-lex.c (init_c_lex): Move declaration to initialization. * c-opts.c (handle_deferred_opts): Move cpp_get_deps call into deferred count loop. --- gcc/c-family/ChangeLog | 8 ++++++++ gcc/c-family/c-common.c | 3 ++- gcc/c-family/c-lex.c | 3 +-- gcc/c-family/c-opts.c | 15 +++++++-------- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index da4be414b6c..90f022c7622 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,11 @@ +2020-05-20 Nathan Sidwell + + * c-common.c (try_to_locate_new_include_insertion_point): Use + strcmp to compare filenames. + * c-lex.c (init_c_lex): Move declaration to initialization. + * c-opts.c (handle_deferred_opts): Move cpp_get_deps call into + deferred count loop. + 2020-05-15 Jason Merrill * c-opts.c (set_std_cxx20): Set flag_coroutines. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index b1379faa412..10c0353fe4e 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -8708,7 +8708,8 @@ try_to_locate_new_include_insertion_point (const char *file, location_t loc) last_ord_map_after_include = NULL; } - if (ord_map->to_file == file) + if (0 == strcmp (ord_map->to_file, file) + && ord_map->to_line) { if (!first_ord_map_in_file) first_ord_map_in_file = ord_map; diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c index f0fa9683b0a..b1cef2345f4 100644 --- a/gcc/c-family/c-lex.c +++ b/gcc/c-family/c-lex.c @@ -60,7 +60,6 @@ static void cb_undef (cpp_reader *, unsigned int, cpp_hashnode *); void init_c_lex (void) { - struct cpp_callbacks *cb; struct c_fileinfo *toplevel; /* The get_fileinfo data structure must be initialized before @@ -73,7 +72,7 @@ init_c_lex (void) toplevel->time = body_time; } - cb = cpp_get_callbacks (parse_in); + struct cpp_callbacks *cb = cpp_get_callbacks (parse_in); cb->line_change = cb_line_change; cb->ident = cb_ident; diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 7695e88c130..8a5131b8ac6 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -1317,15 +1317,14 @@ handle_deferred_opts (void) 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 -- 2.30.2