diff options
-rw-r--r-- | libbuild2/algorithm.cxx | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx index 7fde2a9..3d8b89c 100644 --- a/libbuild2/algorithm.cxx +++ b/libbuild2/algorithm.cxx @@ -375,29 +375,26 @@ namespace build2 if (*mp != nullptr) // Might already be there. return **mp; - target* m (nullptr); - { - pair<target&, ulock> r ( - t.ctx.targets.insert_locked (tt, - move (dir), - move (out), - move (n), - move (ext), - target_decl::implied, - trace, - true /* skip_find */)); - - if (r.second) // Inserted. - { - m = &r.first; - m->group = &t; - } - } + pair<target&, ulock> r ( + t.ctx.targets.insert_locked (tt, + move (dir), + move (out), + move (n), + move (ext), + target_decl::implied, + trace, + true /* skip_find */)); + + target& m (r.first); - assert (m != nullptr); - *mp = m; + if (!r.second) + fail << "target " << m << " already exists and cannot be made " + << "ad hoc member of group " << t; + + m.group = &t; + *mp = &m; - return *m; + return m; }; pair<target&, bool> |