fix #2844 (typedef causes 'syntax error')
This commit is contained in:
parent
e49763b14f
commit
0bd26a73c4
|
@ -1215,23 +1215,41 @@ 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% ) ("))
|
||||
{
|
||||
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")
|
||||
{
|
||||
specStart = tok->tokAt(offset)->link()->next();
|
||||
specEnd = specStart;
|
||||
}
|
||||
argStart = tok->tokAt(offset);
|
||||
argEnd = tok->tokAt(offset)->link();
|
||||
tok = argEnd->next();
|
||||
if (specStart)
|
||||
tok = tok->next();
|
||||
}
|
||||
|
||||
// syntax error
|
||||
else
|
||||
{
|
||||
syntaxError(tok);
|
||||
return;
|
||||
}
|
||||
|
||||
function = true;
|
||||
if (tok->tokAt(offset)->link()->next()->str() == "const")
|
||||
{
|
||||
specStart = tok->tokAt(offset)->link()->next();
|
||||
specEnd = specStart;
|
||||
}
|
||||
argStart = tok->tokAt(offset);
|
||||
argEnd = tok->tokAt(offset)->link();
|
||||
tok = argEnd->next();
|
||||
if (specStart)
|
||||
tok = tok->next();
|
||||
}
|
||||
|
||||
// unhandled typedef, skip it and continue
|
||||
|
|
|
@ -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