Skip to content

Commit d5e34b0

Browse files
authored
Merge pull request #197 from ZehMatt/fix-option-prefix2
Fix a regression that no longer warns if condition is manually defined
2 parents eaa3616 + 916ae11 commit d5e34b0

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/project_parser.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,18 +445,19 @@ Project::Project(const Project *parent, const std::string &path, bool build) : p
445445
options.push_back(o);
446446

447447
// Add a condition matching the option name
448-
conditions.emplace(o.name, o.name);
448+
if (!conditions.emplace(o.name, o.name).second) {
449+
print_key_warning("Option '" + o.name + "' would create a condition '" + o.name + "' that already exists", o.name, value);
450+
}
449451

450452
// Add an implicit condition for the option
451453
auto ncondition = normalize(o.name);
452454
if (ncondition.find(nproject_prefix) == 0) {
453455
ncondition = ncondition.substr(nproject_prefix.size());
454456
}
455457
if (!ncondition.empty() && ncondition != o.name) {
456-
if (conditions.contains(ncondition)) {
458+
if (!conditions.emplace(ncondition, o.name).second) {
457459
print_key_warning("Option '" + o.name + "' would create a condition '" + ncondition + "' that already exists", o.name, value);
458460
}
459-
conditions.emplace(ncondition, o.name);
460461
}
461462
}
462463
}

0 commit comments

Comments
 (0)