aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/algorithm.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-02-22 10:02:44 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-02-22 10:02:44 +0200
commitc8810465be8237ceb3ef96e7512a4762756584ff (patch)
treed2b76367797f9bc4e1c746ce10739d3d562eaf6d /libbuild2/algorithm.cxx
parent626bd6434662436423d0c5cd9689149076ebed07 (diff)
Diagnose instead of asserting ad hoc group member not already existing
Fixes GH issue #365.
Diffstat (limited to 'libbuild2/algorithm.cxx')
-rw-r--r--libbuild2/algorithm.cxx39
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>