Fixed #1378 (#error macro makes unrelated errors undetectable)

This commit is contained in:
Daniel Marjamäki 2018-05-06 22:02:23 +02:00
parent 3b8a3aa4ba
commit 0bff08ca44
1 changed files with 16 additions and 0 deletions

View File

@ -303,6 +303,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
std::set<unsigned long long> checksums;
unsigned int checkCount = 0;
bool hasValidConfig = false;
for (std::set<std::string>::const_iterator it = configurations.begin(); it != configurations.end(); ++it) {
// bail out if terminated
if (_settings.terminated())
@ -362,6 +363,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
timer.Stop();
if (tokensP.empty())
continue;
hasValidConfig = true;
// skip rest of iteration if just checking configuration
if (_settings.checkConfiguration)
@ -442,6 +444,20 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
}
}
if (!hasValidConfig && configurations.size() > 1) {
std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
ErrorLogger::ErrorMessage::FileLocation loc;
loc.setfile(Path::toNativeSeparators(filename));
locationList.push_back(loc);
ErrorLogger::ErrorMessage errmsg(locationList,
loc.getfile(),
Severity::information,
"No tested configuration is valid, this file is not analyzed.",
"noValidConfiguration",
false);
reportErr(errmsg);
}
// dumped all configs, close root </dumps> element now
if (_settings.dump && fdump.is_open())
fdump << "</dumps>" << std::endl;