Fix #1124 (Invalid number of character ((). Can't process file.)
http://sourceforge.net/apps/trac/cppcheck/ticket/1124
This commit is contained in:
parent
11c7b8a839
commit
df0d2ca83c
|
@ -1890,11 +1890,11 @@ std::string Preprocessor::expandMacros(const std::string &code, std::string file
|
|||
// #define B(x) (
|
||||
// #define A() B(xx)
|
||||
// B(1) A() ) )
|
||||
unsigned int macroEnd = line.length() - (pos1 + macrocode.length());
|
||||
unsigned int macroEnd = line.length() - pos2;
|
||||
for (std::map<const PreprocessorMacro *, unsigned int>::iterator iter = limits.begin();
|
||||
iter != limits.end();)
|
||||
{
|
||||
if (macroEnd < iter->second)
|
||||
if (pos1 < iter->second)
|
||||
{
|
||||
// We have gone past this limit, so just delete it
|
||||
limits.erase(iter++);
|
||||
|
|
|
@ -1165,6 +1165,21 @@ private:
|
|||
"B(1) A() ) )\n";
|
||||
ASSERT_EQUALS("\n\n( ( ) )\n", OurPreprocessor::expandMacros(filedata));
|
||||
}
|
||||
|
||||
{
|
||||
const char filedata[] =
|
||||
"#define PTR1 (\n"
|
||||
"#define PTR2 PTR1 PTR1\n"
|
||||
"int PTR2 PTR2 foo )))) = 0;\n";
|
||||
ASSERT_EQUALS("\n\nint ( ( ( ( foo )))) = 0;\n", OurPreprocessor::expandMacros(filedata));
|
||||
}
|
||||
|
||||
{
|
||||
const char filedata[] =
|
||||
"#define PTR1 (\n"
|
||||
"PTR1 PTR1\n";
|
||||
ASSERT_EQUALS("\n( (\n", OurPreprocessor::expandMacros(filedata));
|
||||
}
|
||||
}
|
||||
|
||||
void macro_mismatch()
|
||||
|
|
Loading…
Reference in New Issue