diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 5aa45a0ee..f3ab9e231 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -908,6 +908,8 @@ std::list Preprocessor::getcfgs(const std::string &filedata, const def += ";"; def += *it; } + + /* TODO: Fix TestPreprocessor::test7e (#2552) else { std::ostringstream lineStream; @@ -918,11 +920,12 @@ std::list Preprocessor::getcfgs(const std::string &filedata, const loc.setfile(filename); loc.line = linenr; errmsg._callStack.push_back(loc); - errmsg._severity = Severity::fromString("error"); + errmsg._severity = Severity::error; errmsg.setmsg(*it+" is already guaranteed to be defined"); errmsg._id = "preprocessor" + lineStream.str(); _errorLogger->reportErr(errmsg); } + */ } if (from_negation) { diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 2d9486d49..7163b3af2 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -78,6 +78,11 @@ private: TEST_CASE(test5); TEST_CASE(test6); TEST_CASE(test7); + TEST_CASE(test7a); + TEST_CASE(test7b); + TEST_CASE(test7c); + TEST_CASE(test7d); + TEST_CASE(test7e); // #error => don't extract any code TEST_CASE(error1); @@ -429,8 +434,9 @@ private: preprocessor.preprocess(istr, actual, "file.c"); // Make sure an error message is written.. - ASSERT_EQUALS("[file.c:3]: (error) ABC is already guaranteed to be defined\n", - errout.str()); + TODO_ASSERT_EQUALS("[file.c:3]: (error) ABC is already guaranteed to be defined\n", + "", + errout.str()); // Compare results.. ASSERT_EQUALS("\n\n\n\n\n\n", actual[""]); @@ -511,8 +517,9 @@ private: preprocessor.preprocess(istr, actual, "file.c"); // Make sure an error message is written.. - ASSERT_EQUALS("[file.c:3]: (error) ABC is already guaranteed to be defined\n", - errout.str()); + TODO_ASSERT_EQUALS("[file.c:3]: (error) ABC is already guaranteed to be defined\n", + "", + errout.str()); // Compare results.. ASSERT_EQUALS(2, static_cast(actual.size())); @@ -536,7 +543,36 @@ private: preprocessor.preprocess(istr, actual, "file.c"); // Make sure an error message is written.. - ASSERT_EQUALS("[file.c:3]: (error) ABC is already guaranteed to be defined\n", + TODO_ASSERT_EQUALS("[file.c:3]: (error) ABC is already guaranteed to be defined\n", + "", + errout.str()); + + // Compare results.. + ASSERT_EQUALS(2, static_cast(actual.size())); + } + + void test7e() + { + const char filedata[] = "#ifdef ABC\n" + "#file \"test.h\"\n" + "#ifndef test_h\n" + "#define test_h\n" + "#ifdef ABC\n" + "#endif\n" + "#endif\n" + "#endfile\n" + "#endif\n"; + + // Preprocess => actual result.. + std::istringstream istr(filedata); + std::map actual; + Settings settings; + Preprocessor preprocessor(&settings, this); + errout.str(""); + preprocessor.preprocess(istr, actual, "file.c"); + + // Make sure an error message is written.. + ASSERT_EQUALS("", errout.str()); // Compare results..