aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}