fix #2844 (typedef causes 'syntax error')
This commit is contained in:
parent
e49763b14f
commit
0bd26a73c4
|
@ -1215,12 +1215,22 @@ void Tokenizer::simplifyTypedef()
|
|||
tok = deleteInvalidTypedef(typeDef);
|
||||
continue;
|
||||
}
|
||||
else if (!Token::Match(tok->tokAt(offset)->link(), ") const| ;|,"))
|
||||
|
||||
// function pointer
|
||||
else if (Token::Match(tok->tokAt(offset), "( * %var% ) ("))
|
||||
{
|
||||
syntaxError(tok);
|
||||
return;
|
||||
functionPtr = true;
|
||||
funcStart = tok->tokAt(offset + 1);
|
||||
funcEnd = tok->tokAt(offset)->link()->previous();
|
||||
typeName = tok->tokAt(offset)->link()->tokAt(-2);
|
||||
argStart = tok->tokAt(offset)->link()->next();
|
||||
argEnd = tok->tokAt(offset)->link()->next()->link();
|
||||
tok = argEnd->next();
|
||||
}
|
||||
|
||||
// function
|
||||
else if (Token::Match(tok->tokAt(offset)->link(), ") const| ;|,"))
|
||||
{
|
||||
function = true;
|
||||
if (tok->tokAt(offset)->link()->next()->str() == "const")
|
||||
{
|
||||
|
@ -1234,6 +1244,14 @@ void Tokenizer::simplifyTypedef()
|
|||
tok = tok->next();
|
||||
}
|
||||
|
||||
// syntax error
|
||||
else
|
||||
{
|
||||
syntaxError(tok);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// unhandled typedef, skip it and continue
|
||||
else
|
||||
{
|
||||
|
|
|
@ -259,6 +259,7 @@ private:
|
|||
TEST_CASE(simplifyTypedef92); // ticket #2736
|
||||
TEST_CASE(simplifyTypedef93); // ticket #2738
|
||||
TEST_CASE(simplifyTypedef94); // ticket #1982
|
||||
TEST_CASE(simplifyTypedef95); // ticket #2844
|
||||
|
||||
TEST_CASE(simplifyTypedefFunction1);
|
||||
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
||||
|
@ -5323,6 +5324,15 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedef95() // ticket #2844
|
||||
{
|
||||
const char code1[] = "class symbol_table {\n"
|
||||
"public:\n"
|
||||
" typedef expression_error::error_code (*valid_func)(void *cbparam, const char *name, expression_space space);\n"
|
||||
"};\n";
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedefFunction1()
|
||||
{
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue