diff options
author | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2025-02-04 17:21:42 -0800 |
---|---|---|
committer | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2025-02-04 17:35:57 -0800 |
commit | e41a5a2a0832509fa1c0b7cab0c8001fadbd23d4 (patch) | |
tree | fd3dcb81cce92692a397e1365eb81d25f15701ff /gcc/fortran/cpp.cc | |
parent | f2a8f3c364a0d196efb0687ea421190b46d041d5 (diff) | |
download | gcc-e41a5a2a0832509fa1c0b7cab0c8001fadbd23d4.zip gcc-e41a5a2a0832509fa1c0b7cab0c8001fadbd23d4.tar.gz gcc-e41a5a2a0832509fa1c0b7cab0c8001fadbd23d4.tar.bz2 |
Fortran: Fix PR 47485.
The -MT and -MQ options should replace the default target in the
generated dependency file. deps_add_target needs to be called before
cpp_read_main_file, otherwise the original object name is added.
Contributed by Vincent Vanlaer <vincenttc@volkihar.be>
PR fortran/47485
gcc/fortran/ChangeLog:
* cpp.cc: fix -MT/-MQ adding additional target instead of
replacing the default.
gcc/testsuite/ChangeLog:
* gfortran.dg/dependency_generation_1.f90: New test.
Signed-off-by: Vincent Vanlaer <vincenttc@volkihar.be>
Diffstat (limited to 'gcc/fortran/cpp.cc')
-rw-r--r-- | gcc/fortran/cpp.cc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/gcc/fortran/cpp.cc b/gcc/fortran/cpp.cc index 6956799..1b70420 100644 --- a/gcc/fortran/cpp.cc +++ b/gcc/fortran/cpp.cc @@ -96,6 +96,8 @@ struct gfc_cpp_option_data int deps_skip_system; /* -MM */ const char *deps_filename; /* -M[M]D */ const char *deps_filename_user; /* -MF <arg> */ + const char *deps_target_filename; /* -MT / -MQ <arg> */ + bool quote_deps_target_filename; /* -MQ */ int deps_missing_are_generated; /* -MG */ int deps_phony; /* -MP */ int warn_date_time; /* -Wdate-time */ @@ -287,6 +289,8 @@ gfc_cpp_init_options (unsigned int decoded_options_count, gfc_cpp_option.deps_missing_are_generated = 0; gfc_cpp_option.deps_filename = NULL; gfc_cpp_option.deps_filename_user = NULL; + gfc_cpp_option.deps_target_filename = NULL; + gfc_cpp_option.quote_deps_target_filename = false; gfc_cpp_option.multilib = NULL; gfc_cpp_option.prefix = NULL; @@ -439,9 +443,8 @@ gfc_cpp_handle_option (size_t scode, const char *arg, int value ATTRIBUTE_UNUSED case OPT_MQ: case OPT_MT: - gfc_cpp_option.deferred_opt[gfc_cpp_option.deferred_opt_count].code = code; - gfc_cpp_option.deferred_opt[gfc_cpp_option.deferred_opt_count].arg = arg; - gfc_cpp_option.deferred_opt_count++; + gfc_cpp_option.quote_deps_target_filename = (code == OPT_MQ); + gfc_cpp_option.deps_target_filename = arg; break; case OPT_P: @@ -593,6 +596,12 @@ gfc_cpp_init_0 (void) } gcc_assert(cpp_in); + + if (gfc_cpp_option.deps_target_filename) + if (mkdeps *deps = cpp_get_deps (cpp_in)) + deps_add_target (deps, gfc_cpp_option.deps_target_filename, + gfc_cpp_option.quote_deps_target_filename); + if (!cpp_read_main_file (cpp_in, gfc_source_file)) errorcount++; } @@ -635,9 +644,6 @@ gfc_cpp_init (void) else cpp_assert (cpp_in, opt->arg); } - else if (opt->code == OPT_MT || opt->code == OPT_MQ) - if (mkdeps *deps = cpp_get_deps (cpp_in)) - deps_add_target (deps, opt->arg, opt->code == OPT_MQ); } /* Pre-defined macros for non-required INTEGER kind types. */ |