Merge pull request #195 from simartin/ticket_5139

Ticket #5139: Properly handle recursive macro definitions
This commit is contained in:
Daniel Marjamäki 2013-11-02 11:21:13 -07:00
commit a50e5c2c23
2 changed files with 17 additions and 1 deletions

View File

@ -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);
}
}

View File

@ -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"