From 724ed2aaab1754bdc13215e707c04533752fe95b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 24 Jan 2016 10:47:10 +0200 Subject: Fix bug in dynamically derived target types --- build2/parser.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'build2') 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; } -- cgit v1.1