Fixed #4838 (False positive for ... seems to be invalid)

This commit is contained in:
Daniel Marjamäki 2013-06-06 12:44:19 +02:00
parent f5a3492e3a
commit 9eac4489ac
3 changed files with 6 additions and 6 deletions

View File

@ -2741,7 +2741,7 @@ bool Preprocessor::validateCfg(const std::string &code, const std::string &cfg)
continue;
// macro is used in code, return false
if (_settings->isEnabled("information"))
validateCfgError(cfg);
validateCfgError(cfg, macro);
return false;
}
}
@ -2750,7 +2750,7 @@ bool Preprocessor::validateCfg(const std::string &code, const std::string &cfg)
return true;
}
void Preprocessor::validateCfgError(const std::string &cfg)
void Preprocessor::validateCfgError(const std::string &cfg, const std::string &macro)
{
const std::string id = "ConfigurationNotChecked";
std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
@ -2758,7 +2758,7 @@ void Preprocessor::validateCfgError(const std::string &cfg)
loc.line = 1;
loc.setfile(file0);
locationList.push_back(loc);
ErrorLogger::ErrorMessage errmsg(locationList, Severity::information, "Skipping configuration '" + cfg + "' because it seems to be invalid. Use -D if you want to check it.", id, false);
ErrorLogger::ErrorMessage errmsg(locationList, Severity::information, "Skipping configuration '" + cfg + "' since the value of '" + macro + "' is unknown. Use -D if you want to check it.", id, false);
_errorLogger->reportInfo(errmsg);
}
@ -3041,6 +3041,6 @@ void Preprocessor::getErrorMessages(ErrorLogger *errorLogger, const Settings *se
settings2.checkConfiguration=true;
preprocessor.missingInclude("", 1, "", UserHeader);
preprocessor.missingInclude("", 1, "", SystemHeader);
preprocessor.validateCfgError("X");
preprocessor.validateCfgError("X", "X");
preprocessor.error("", 1, "#error message"); // #error ..
}

View File

@ -122,7 +122,7 @@ public:
* @return true => configuration is valid
*/
bool validateCfg(const std::string &code, const std::string &cfg);
void validateCfgError(const std::string &cfg);
void validateCfgError(const std::string &cfg, const std::string &macro);
void handleUndef(std::list<std::string> &configurations) const;

View File

@ -3766,7 +3766,7 @@ private:
settings.addEnabled("all");
preprocessor.setFile0("test.c");
ASSERT_EQUALS(false, preprocessor.validateCfg("int a=A;", "A"));
ASSERT_EQUALS("[test.c:1]: (information) Skipping configuration 'A' because it seems to be invalid. Use -D if you want to check it.\n", errout.str());
ASSERT_EQUALS("[test.c:1]: (information) Skipping configuration 'A' since the value of 'A' is unknown. Use -D if you want to check it.\n", errout.str());
}
void if_sizeof() { // #4071