Preprocessor: handle '#undef' better. Ticket: #2131
This commit is contained in:
parent
08ba378730
commit
0eb4e3032a
|
@ -1798,6 +1798,10 @@ std::string Preprocessor::handleIncludes(const std::string &code, const std::str
|
|||
}
|
||||
}
|
||||
|
||||
else if (line.compare(0,7,"#undef ") == 0) {
|
||||
defs.erase(line.substr(7));
|
||||
}
|
||||
|
||||
else {
|
||||
ostr << line;
|
||||
}
|
||||
|
|
|
@ -2912,6 +2912,22 @@ private:
|
|||
ASSERT_EQUALS("\n\n\n\n\n\n\n4\n\n", actual);
|
||||
}
|
||||
}
|
||||
|
||||
// #undef
|
||||
{
|
||||
const std::string code("#ifndef X\n"
|
||||
"#define X\n"
|
||||
"123\n"
|
||||
"#endif\n");
|
||||
|
||||
defs.clear();
|
||||
const std::string actual1(preprocessor.handleIncludes(code,filePath,includePaths,defs));
|
||||
|
||||
defs.clear();
|
||||
const std::string actual(preprocessor.handleIncludes(code + "#undef X\n" + code, filePath, includePaths, defs));
|
||||
|
||||
ASSERT_EQUALS(actual1 + "\n" + actual1, actual);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue