summaryrefslogtreecommitdiffstats
path: root/src/state.cc
diff options
context:
space:
mode:
authorJan Niklas Hasse <jhasse@bixense.com>2023-12-06 19:49:28 (GMT)
committerJan Niklas Hasse <jhasse@bixense.com>2023-12-06 19:49:28 (GMT)
commit4d98903d4c986f720ddb3f18d32c1125ef3e680e (patch)
tree17180e557abef89aa1f396b3c3c83ffa508c29c6 /src/state.cc
parent8f47d5aa33c6c303a71093be2eac02672dfb2966 (diff)
downloadNinja-4d98903d4c986f720ddb3f18d32c1125ef3e680e.zip
Ninja-4d98903d4c986f720ddb3f18d32c1125ef3e680e.tar.gz
Ninja-4d98903d4c986f720ddb3f18d32c1125ef3e680e.tar.bz2
Improve misleading error message when an output is defined multiple times
Diffstat (limited to 'src/state.cc')
-rw-r--r--src/state.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/state.cc b/src/state.cc
index 0a68f21..d4b9a71 100644
--- a/src/state.cc
+++ b/src/state.cc
@@ -133,10 +133,17 @@ void State::AddIn(Edge* edge, StringPiece path, uint64_t slash_bits) {
node->AddOutEdge(edge);
}
-bool State::AddOut(Edge* edge, StringPiece path, uint64_t slash_bits) {
+bool State::AddOut(Edge* edge, StringPiece path, uint64_t slash_bits,
+ std::string* err) {
Node* node = GetNode(path, slash_bits);
- if (node->in_edge())
+ if (Edge* other = node->in_edge()) {
+ if (other == edge) {
+ *err = path.AsString() + " is defined as an output multiple times";
+ } else {
+ *err = "multiple rules generate " + path.AsString();
+ }
return false;
+ }
edge->outputs_.push_back(node);
node->set_in_edge(edge);
node->set_generated_by_dep_loader(false);