Fixed ticket 147 (Invalid line number for error message)

This commit is contained in:
Daniel Marjamäki 2009-03-09 20:29:25 +01:00
parent f39e117921
commit cd54a0ed3b
2 changed files with 9 additions and 2 deletions

View File

@ -806,6 +806,9 @@ std::string Preprocessor::expandMacros(std::string code)
std::string::size_type pos2 = pos1 + macro.name().length(); std::string::size_type pos2 = pos1 + macro.name().length();
if (macro.params().size() && pos2 >= code.length()) if (macro.params().size() && pos2 >= code.length())
continue; continue;
unsigned int numberOfNewlines = 0;
if (macro.params().size()) if (macro.params().size())
{ {
if (code[pos2] != '(') if (code[pos2] != '(')
@ -850,6 +853,10 @@ std::string Preprocessor::expandMacros(std::string code)
par += code[pos2]; par += code[pos2];
continue; continue;
} }
else if (code[pos2] == '\n')
{
++numberOfNewlines;
}
if (parlevel == 1 && code[pos2] == ',') if (parlevel == 1 && code[pos2] == ',')
{ {
@ -868,7 +875,7 @@ std::string Preprocessor::expandMacros(std::string code)
continue; continue;
// Create macro code.. // Create macro code..
const std::string macrocode(macro.code(params)); const std::string macrocode(std::string(numberOfNewlines, '\n') + macro.code(params));
// Insert macro code.. // Insert macro code..
if (!macro.params().empty()) if (!macro.params().empty())

View File

@ -95,7 +95,7 @@ private:
TEST_CASE(macro_simple7); TEST_CASE(macro_simple7);
TEST_CASE(macro_simple8); TEST_CASE(macro_simple8);
TEST_CASE(macro_mismatch); TEST_CASE(macro_mismatch);
// TODO TEST_CASE(macro_linenumbers); TEST_CASE(macro_linenumbers);
TEST_CASE(string1); TEST_CASE(string1);
TEST_CASE(string2); TEST_CASE(string2);
TEST_CASE(preprocessor_undef); TEST_CASE(preprocessor_undef);