aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-09-09 14:17:49 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-09-09 14:17:49 +0200
commit05cba8680738c754d6ca46b8ead5030f633295b2 (patch)
treeb80a3537c947f6752f46e88941558e235892beb4
parentd7acc2a73594eed81ec8b3227b90a0f18944eedf (diff)
Temporary variable lookup instrumentation
-rw-r--r--libbuild2/target.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/libbuild2/target.cxx b/libbuild2/target.cxx
index 78bc5ac..c78fc57 100644
--- a/libbuild2/target.cxx
+++ b/libbuild2/target.cxx
@@ -158,13 +158,21 @@ namespace build2
{
++r.second;
+#if 1
// In case of an ad hoc group, we may have to look in two groups.
//
if ((g1 = group) != nullptr)
{
auto p (g1->vars.lookup (var));
if (p.first != nullptr)
+ {
+ if (g1->adhoc_group ())
+ fail << "ad hoc group variable lookup " << var <<
+ info << "member " << *this <<
+ info << "group " << *g1;
+
r.first = lookup_type (*p.first, p.second, g1->vars);
+ }
else
{
if ((g2 = g1->group) != nullptr)
@@ -175,6 +183,19 @@ namespace build2
}
}
}
+#else
+ // Skip looking up in the ad hoc group, which is semantically the
+ // first/primary member.
+ //
+ if ((g1 = group == nullptr
+ ? nullptr
+ : group->adhoc_group () ? group->group : group))
+ {
+ auto p (g1->vars.lookup (var));
+ if (p.first != nullptr)
+ r.first = lookup_type (*p.first, p.second, g1->vars);
+ }
+#endif
}
// Delegate to scope's lookup_original().
@@ -195,6 +216,17 @@ namespace build2
g1 != nullptr ? &g1k : nullptr,
g2 != nullptr ? &g2k : nullptr));
+ if (p.first && g1 != nullptr && g1->adhoc_group ())
+ {
+ for (size_t d (2); d <= p.second; d += 3)
+ {
+ if (p.second == d)
+ fail << "ad hoc group type/pattern variable lookup " << var <<
+ info << "member " << *this <<
+ info << "group " << *g1;
+ }
+ }
+
r.first = move (p.first);
r.second = r.first ? r.second + p.second : p.second;
}