From eb9e8b2083de81b49284a907607c7ef380cf9f8a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 13 Dec 2023 12:29:02 +0200 Subject: Fix another instance of module name not being assigned due to deferred failure --- libbuild2/cc/compile-rule.cxx | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'libbuild2/cc/compile-rule.cxx') diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx index d40638c..e993048 100644 --- a/libbuild2/cc/compile-rule.cxx +++ b/libbuild2/cc/compile-rule.cxx @@ -6070,10 +6070,18 @@ namespace build2 // if (pt->is_a ()) { - const string& n (cast (pt->state[a].vars[c_module_name])); - - if (const target** p = check_exact (n)) - *p = pt; + // If the extraction of the module information for this BMI failed + // and we have deferred failure to compiler diagnostics, then + // there will be no module name assigned. It would have been + // better to make sure that's the cause, but that won't be easy. + // + const string* n (cast_null ( + pt->state[a].vars[c_module_name])); + if (n != nullptr) + { + if (const target** p = check_exact (*n)) + *p = pt; + } } else if (pt->is_a (*x_mod)) { @@ -6082,7 +6090,8 @@ namespace build2 // rule puts them into prerequisite_targets for us). // // The module names should be specified but if not assume - // something else is going on and ignore. + // something else is going on (like a deferred failure) and + // ignore. // // Note also that besides modules, prerequisite_targets may // contain libraries which are interface dependencies of this @@ -6476,12 +6485,10 @@ namespace build2 if (m.score <= match_max (in)) { - // If the extraction of the module information for this BMI failed - // and we have deferred failure to compiler diagnostics, then there - // will be no module name assigned. It would have been better to - // make sure that's the cause, but that won't be easy. + // As above (deffered failure). // - const string* mn (cast_null (bt->state[a].vars[c_module_name])); + const string* mn ( + cast_null (bt->state[a].vars[c_module_name])); if (mn != nullptr && in != *mn) { -- cgit v1.1