Fixed #2571 (Preprocessor: better handling for #undef)
This commit is contained in:
parent
751f8d46e5
commit
f2f2d1f885
|
@ -1544,7 +1544,8 @@ std::string Preprocessor::getcode(const std::string &filedata, std::string cfg,
|
|||
return "";
|
||||
}
|
||||
|
||||
if (!match && line.compare(0, 8, "#define ") == 0)
|
||||
if (!match && (line.compare(0, 8, "#define ") == 0 ||
|
||||
line.compare(0, 6, "#undef") == 0))
|
||||
{
|
||||
// Remove define that is not part of this configuration
|
||||
line = "";
|
||||
|
|
|
@ -2483,6 +2483,25 @@ private:
|
|||
ASSERT_EQUALS("\n\n1\n\n", actual[""]);
|
||||
ASSERT_EQUALS(1, (int)actual.size());
|
||||
}
|
||||
|
||||
{
|
||||
const char filedata[] = "#define A 1\n"
|
||||
"#if 0\n"
|
||||
"#undef A\n"
|
||||
"#endif\n"
|
||||
"A\n";
|
||||
|
||||
// Preprocess => actual result..
|
||||
std::istringstream istr(filedata);
|
||||
std::map<std::string, std::string> actual;
|
||||
Settings settings;
|
||||
Preprocessor preprocessor(&settings, this);
|
||||
preprocessor.preprocess(istr, actual, "file.c");
|
||||
|
||||
// Compare results..
|
||||
ASSERT_EQUALS("\n\n\n\n1\n", actual[""]);
|
||||
ASSERT_EQUALS(1, (int)actual.size());
|
||||
}
|
||||
}
|
||||
|
||||
void define_ifndef1()
|
||||
|
|
Loading…
Reference in New Issue