Skip to content

Commit

Permalink
Fixed ticket danmar#3675.
Browse files Browse the repository at this point in the history
  • Loading branch information
leg0 committed Mar 22, 2012
1 parent d04698d commit 780481e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ static void simplifyVarMap(std::map<std::string, std::string> &variables)
// TODO: 2. handle function-macros too.

std::map<std::string, std::string>::iterator it = variables.find(varValue);
while (it != variables.end() && it != i) {
while (it != variables.end() && it->first != it->second && it != i) {
varValue = it->second;
it = variables.find(varValue);
}
Expand Down
18 changes: 18 additions & 0 deletions test/testpreprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class TestPreprocessor : public TestFixture {
TEST_CASE(if_or_2);

TEST_CASE(if_macro_eq_macro); // #3536
TEST_CASE(ticket_3675);

TEST_CASE(multiline1);
TEST_CASE(multiline2);
Expand Down Expand Up @@ -1521,6 +1522,23 @@ class TestPreprocessor : public TestFixture {
ASSERT_EQUALS("\n\n\n\nWilma\n\n\n\n", actual[""]);
}

void ticket_3675() {
const std::string code("#ifdef YYSTACKSIZE\n"
"#define YYMAXDEPTH YYSTACKSIZE\n"
"#else\n"
"#define YYSTACKSIZE YYMAXDEPTH\n"
"#endif\n"
"#if YYDEBUG\n"
"#endif\n");
Settings settings;
Preprocessor preprocessor(&settings, this);
std::istringstream istr(code);
std::map<std::string, std::string> actual;
preprocessor.preprocess(istr, actual, "file.c");

// There's nothing to assert. It just needs to not hang.
}

void multiline1() {
const char filedata[] = "#define str \"abc\" \\\n"
" \"def\" \n"
Expand Down

0 comments on commit 780481e

Please sign in to comment.