diff options
author | Brad King <brad.king@kitware.com> | 2020-11-10 17:12:23 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-11-17 18:22:52 (GMT) |
commit | d800c26ce947c01dc32871614c137f7c9bdce3cb (patch) | |
tree | 96928959bcca3f00e28167e713c81ee8a7842435 /Source/cmake.cxx | |
parent | c0619861c9b4455c785c64d1d7b8cfcf8de5b9ae (diff) | |
download | CMake-d800c26ce947c01dc32871614c137f7c9bdce3cb.zip CMake-d800c26ce947c01dc32871614c137f7c9bdce3cb.tar.gz CMake-d800c26ce947c01dc32871614c137f7c9bdce3cb.tar.bz2 |
cmake: Fix processing of -Wno-error= flags
Fix two bugs that happened to cancel each other out for cases covered
by our test suite. Add a test case that distinguishes them.
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 4a2bb49..4fb0f2b 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -427,12 +427,12 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) bool foundError = false; unsigned int nameStartPosition = 0; - if (entry.find("no-", nameStartPosition) == 0) { + if (entry.find("no-", nameStartPosition) == nameStartPosition) { foundNo = true; nameStartPosition += 3; } - if (entry.find("error=", nameStartPosition) == 0) { + if (entry.find("error=", nameStartPosition) == nameStartPosition) { foundError = true; nameStartPosition += 6; } @@ -454,7 +454,12 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) this->DiagLevels[name] = DIAG_ERROR; } else { // -Wno-error=<name> - this->DiagLevels[name] = std::min(this->DiagLevels[name], DIAG_WARN); + // This can downgrade an error to a warning, but should not enable + // or disable a warning in the first place. + auto dli = this->DiagLevels.find(name); + if (dli != this->DiagLevels.end()) { + dli->second = std::min(dli->second, DIAG_WARN); + } } } else if (cmHasLiteralPrefix(arg, "-U")) { std::string entryPattern = arg.substr(2); |