diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-01-24 10:47:10 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-01-24 10:47:10 +0200 |
commit | 724ed2aaab1754bdc13215e707c04533752fe95b (patch) | |
tree | f341a7ed442a98d941077c7b30773912d17e8ee7 | |
parent | 3e39190bc50284a620605c7b61faff197e116457 (diff) |
Fix bug in dynamically derived target types
-rw-r--r-- | build2/parser.cxx | 9 | ||||
-rw-r--r-- | tests/define/buildfile | 2 |
2 files changed, 9 insertions, 2 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; } diff --git a/tests/define/buildfile b/tests/define/buildfile index 55b9e92..d85fc57 100644 --- a/tests/define/buildfile +++ b/tests/define/buildfile @@ -9,6 +9,6 @@ foo{FOO}: # verify name is foo{FOO} and not file{FOO} with --verbose 6 #define foo: dir # already define in this scope define bar: foo -bar{BAR}: # verify name is bar{FOO} with --verbose 6 +bar{BAR}: # verify name is bar{BAR} with --verbose 6 ./: |