Ticket #5139: Properly simplify recursive macro definitions
This commit is contained in:
parent
ac3b1c0611
commit
95c08d5613
|
@ -1134,7 +1134,7 @@ static Token *simplifyVarMapExpandValue(Token *tok, const std::map<std::string,
|
|||
// expand token list
|
||||
for (Token *tok2 = tokenList.front(); tok2; tok2 = tok2->next()) {
|
||||
if (tok2->isName()) {
|
||||
simplifyVarMapExpandValue(tok2, variables, seenVariables);
|
||||
tok2 = simplifyVarMapExpandValue(tok2, variables, seenVariables);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -95,6 +95,7 @@ private:
|
|||
TEST_CASE(test7e);
|
||||
TEST_CASE(test8); // #if A==1 => cfg: A=1
|
||||
TEST_CASE(test9); // Don't crash for invalid code
|
||||
TEST_CASE(test10); // Ticket #5139
|
||||
|
||||
// #error => don't extract any code
|
||||
TEST_CASE(error1);
|
||||
|
@ -794,6 +795,21 @@ private:
|
|||
Preprocessor preprocessor(&settings, this);
|
||||
preprocessor.preprocess(istr, actual, "file.c"); // <- don't crash
|
||||
}
|
||||
|
||||
void test10() { // Ticket #5139
|
||||
const char filedata[] = "#define foo a.foo\n"
|
||||
"#define bar foo\n"
|
||||
"#define baz bar+0\n"
|
||||
"#if 0\n"
|
||||
"#endif";
|
||||
|
||||
// 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");
|
||||
}
|
||||
|
||||
void error1() {
|
||||
const char filedata[] = "#ifdef A\n"
|
||||
|
|
Loading…
Reference in New Issue