fix #2844 fix to generate correct output

This commit is contained in:
Robert Reif 2011-06-19 20:19:16 -04:00
parent 0bd26a73c4
commit d80a55267c
2 changed files with 19 additions and 8 deletions

View File

@ -1219,12 +1219,14 @@ void Tokenizer::simplifyTypedef()
// function pointer // function pointer
else if (Token::Match(tok->tokAt(offset), "( * %var% ) (")) else if (Token::Match(tok->tokAt(offset), "( * %var% ) ("))
{ {
// name token wasn't a name, it was part of the type
typeEnd = typeEnd->next();
functionPtr = true; functionPtr = true;
funcStart = tok->tokAt(offset + 1); funcStart = tok->tokAt(offset + 1);
funcEnd = tok->tokAt(offset)->link()->previous(); funcEnd = tok->tokAt(offset + 1);
typeName = tok->tokAt(offset)->link()->tokAt(-2); typeName = tok->tokAt(offset + 2);
argStart = tok->tokAt(offset)->link()->next(); argStart = tok->tokAt(offset + 4);
argEnd = tok->tokAt(offset)->link()->next()->link(); argEnd = tok->tokAt(offset + 4)->link();
tok = argEnd->next(); tok = argEnd->next();
} }

View File

@ -5326,10 +5326,19 @@ private:
void simplifyTypedef95() // ticket #2844 void simplifyTypedef95() // ticket #2844
{ {
const char code1[] = "class symbol_table {\n" const char code[] = "class symbol_table {\n"
"public:\n" "public:\n"
" typedef expression_error::error_code (*valid_func)(void *cbparam, const char *name, expression_space space);\n" " typedef expression_error::error_code (*valid_func)(void *cbparam, const char *name, expression_space space);\n"
" valid_func f;\n"
"};\n"; "};\n";
const char expected[] = "class symbol_table { "
"public: "
"; "
"expression_error :: error_code ( * f ) ( void * cbparam , const char * name , expression_space space ) ; "
"} ;";
checkSimplifyTypedef(code);
ASSERT_EQUALS(expected, sizeof_(code));
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }