aboutsummaryrefslogtreecommitdiff
path: root/build2
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-01-24 10:47:10 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-01-24 10:47:10 +0200
commit724ed2aaab1754bdc13215e707c04533752fe95b (patch)
treef341a7ed442a98d941077c7b30773912d17e8ee7 /build2
parent3e39190bc50284a620605c7b61faff197e116457 (diff)
Fix bug in dynamically derived target types
Diffstat (limited to 'build2')
-rw-r--r--build2/parser.cxx9
1 files changed, 8 insertions, 1 deletions
diff --git a/build2/parser.cxx b/build2/parser.cxx
index 7e07834..c632c80 100644
--- a/build2/parser.cxx
+++ b/build2/parser.cxx
@@ -888,7 +888,14 @@ namespace build2
// being called to construct a derived target. This can be used, for
// example, to decide whether to "link up" to the group.
//
- target* r (t.base->factory (t, move (d), move (n), e));
+ // One exception: if we are derived from a derived target type, the this
+ // logic will lead to infinite recursion. In this case get the ultimate
+ // base.
+ //
+ const target_type* bt (t.base);
+ for (; bt->factory == &derived_factory; bt = bt->base) ;
+
+ target* r (bt->factory (t, move (d), move (n), e));
r->derived_type = &t;
return r;
}