From 780481e82a40d8665afd832c079bdb5d12753618 Mon Sep 17 00:00:00 2001 From: Ahti Legonkov Date: Fri, 23 Mar 2012 01:45:47 +0200 Subject: [PATCH] Fixed ticket #3675. --- lib/preprocessor.cpp | 2 +- test/testpreprocessor.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 3326f6df5..e747ab837 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -889,7 +889,7 @@ static void simplifyVarMap(std::map &variables) // TODO: 2. handle function-macros too. std::map::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); } diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 99761bbc5..aa8fef626 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -129,6 +129,7 @@ private: TEST_CASE(if_or_2); TEST_CASE(if_macro_eq_macro); // #3536 + TEST_CASE(ticket_3675); TEST_CASE(multiline1); TEST_CASE(multiline2); @@ -1521,6 +1522,23 @@ private: 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 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"