Don't set Preprocessor::missingIncludeFlag if missingInclude warning is suppressed (#3487).
This commit is contained in:
parent
0157f937bf
commit
279b0c59bb
|
@ -1915,7 +1915,7 @@ std::string Preprocessor::handleIncludes(const std::string &code, const std::str
|
||||||
if (!openHeader(filename, includePaths, filepath, fin)) {
|
if (!openHeader(filename, includePaths, filepath, fin)) {
|
||||||
|
|
||||||
if (_settings && (headerType == UserHeader || _settings->debugwarnings)) {
|
if (_settings && (headerType == UserHeader || _settings->debugwarnings)) {
|
||||||
if (!_settings->nomsg.isSuppressed("missingInclude", "", 0)) {
|
if (!_settings->nomsg.isSuppressed("missingInclude", filename, linenr)) {
|
||||||
missingIncludeFlag = true;
|
missingIncludeFlag = true;
|
||||||
|
|
||||||
missingInclude(Path::toNativeSeparators(filePath),
|
missingInclude(Path::toNativeSeparators(filePath),
|
||||||
|
@ -2023,33 +2023,31 @@ void Preprocessor::handleIncludes(std::string &code, const std::string &filePath
|
||||||
path.erase(1 + path.find_last_of("\\/"));
|
path.erase(1 + path.find_last_of("\\/"));
|
||||||
paths.push_back(path);
|
paths.push_back(path);
|
||||||
} else if (!fileOpened && _settings && (headerType == UserHeader || _settings->debugwarnings)) {
|
} else if (!fileOpened && _settings && (headerType == UserHeader || _settings->debugwarnings)) {
|
||||||
if (!_settings->nomsg.isSuppressed("missingInclude", "", 0))
|
std::string f = filePath;
|
||||||
missingIncludeFlag = true;
|
|
||||||
|
|
||||||
if (_errorLogger && _settings->checkConfiguration) {
|
// Determine line number of include
|
||||||
std::string f = filePath;
|
unsigned int linenr = 1;
|
||||||
|
unsigned int level = 0;
|
||||||
// Determine line number of include
|
for (std::string::size_type p = 1; p <= pos; ++p) {
|
||||||
unsigned int linenr = 1;
|
if (level == 0 && code[pos-p] == '\n')
|
||||||
unsigned int level = 0;
|
++linenr;
|
||||||
for (std::string::size_type p = 1; p <= pos; ++p) {
|
else if (code.compare(pos-p, 9, "#endfile\n") == 0) {
|
||||||
if (level == 0 && code[pos-p] == '\n')
|
++level;
|
||||||
++linenr;
|
} else if (code.compare(pos-p, 6, "#file ") == 0) {
|
||||||
else if (code.compare(pos-p, 9, "#endfile\n") == 0) {
|
if (level == 0) {
|
||||||
++level;
|
linenr--;
|
||||||
} else if (code.compare(pos-p, 6, "#file ") == 0) {
|
const std::string::size_type pos1 = pos - p + 7;
|
||||||
if (level == 0) {
|
const std::string::size_type pos2 = code.find_first_of("\"\n", pos1);
|
||||||
linenr--;
|
f = code.substr(pos1, (pos2 == std::string::npos) ? pos2 : (pos2 - pos1));
|
||||||
const std::string::size_type pos1 = pos - p + 7;
|
break;
|
||||||
const std::string::size_type pos2 = code.find_first_of("\"\n", pos1);
|
|
||||||
f = code.substr(pos1, (pos2 == std::string::npos) ? pos2 : (pos2 - pos1));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
--level;
|
|
||||||
}
|
}
|
||||||
|
--level;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!_settings->nomsg.isSuppressed("missingInclude", f, linenr)) {
|
if (!_settings->nomsg.isSuppressed("missingInclude", f, linenr)) {
|
||||||
|
missingIncludeFlag = true;
|
||||||
|
if (_errorLogger && _settings->checkConfiguration) {
|
||||||
missingInclude(Path::toNativeSeparators(f),
|
missingInclude(Path::toNativeSeparators(f),
|
||||||
linenr,
|
linenr,
|
||||||
filename,
|
filename,
|
||||||
|
|
|
@ -2912,6 +2912,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void inline_suppression_for_missing_include() {
|
void inline_suppression_for_missing_include() {
|
||||||
|
Preprocessor::missingIncludeFlag = false;
|
||||||
Settings settings;
|
Settings settings;
|
||||||
settings._inlineSuppressions = true;
|
settings._inlineSuppressions = true;
|
||||||
settings.addEnabled("all");
|
settings.addEnabled("all");
|
||||||
|
@ -2928,6 +2929,7 @@ private:
|
||||||
errout.str("");
|
errout.str("");
|
||||||
preprocessor.preprocess(src, processedFile, cfg, "test.c", paths);
|
preprocessor.preprocess(src, processedFile, cfg, "test.c", paths);
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
ASSERT_EQUALS(false, Preprocessor::missingIncludeFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void predefine1() {
|
void predefine1() {
|
||||||
|
|
Loading…
Reference in New Issue