Fixed #5614 (Incorrect syntax error with function pointer typedef and dependent template types)
This commit is contained in:
parent
1a1f2069e9
commit
82527422a8
|
@ -798,6 +798,15 @@ void Tokenizer::simplifyTypedef()
|
||||||
|
|
||||||
// or a function typedef
|
// or a function typedef
|
||||||
else if (tokOffset && tokOffset->str() == "(") {
|
else if (tokOffset && tokOffset->str() == "(") {
|
||||||
|
Token *tokOffset2 = nullptr;
|
||||||
|
if (Token::Match(tokOffset, "( *|%name%")) {
|
||||||
|
tokOffset2 = tokOffset->next();
|
||||||
|
if (tokOffset2->str() == "typename")
|
||||||
|
tokOffset2 = tokOffset2->next();
|
||||||
|
while (Token::Match(tokOffset2, "%type% ::"))
|
||||||
|
tokOffset2 = tokOffset2->tokAt(2);
|
||||||
|
}
|
||||||
|
|
||||||
// unhandled typedef, skip it and continue
|
// unhandled typedef, skip it and continue
|
||||||
if (typeName->str() == "void") {
|
if (typeName->str() == "void") {
|
||||||
unsupportedTypedef(typeDef);
|
unsupportedTypedef(typeDef);
|
||||||
|
@ -809,14 +818,12 @@ void Tokenizer::simplifyTypedef()
|
||||||
}
|
}
|
||||||
|
|
||||||
// function pointer
|
// function pointer
|
||||||
else if (Token::Match(tokOffset, "( * %name% ) (")) {
|
else if (Token::Match(tokOffset2, "* %name% ) (")) {
|
||||||
// name token wasn't a name, it was part of the type
|
// name token wasn't a name, it was part of the type
|
||||||
typeEnd = typeEnd->next();
|
typeEnd = typeEnd->next();
|
||||||
functionPtr = true;
|
functionPtr = true;
|
||||||
tokOffset = tokOffset->next();
|
funcStart = funcEnd = tokOffset2; // *
|
||||||
funcStart = tokOffset;
|
tokOffset = tokOffset2->tokAt(3); // (
|
||||||
funcEnd = tokOffset;
|
|
||||||
tokOffset = tokOffset->tokAt(3);
|
|
||||||
typeName = tokOffset->tokAt(-2);
|
typeName = tokOffset->tokAt(-2);
|
||||||
argStart = tokOffset;
|
argStart = tokOffset;
|
||||||
argEnd = tokOffset->link();
|
argEnd = tokOffset->link();
|
||||||
|
|
|
@ -2329,6 +2329,11 @@ private:
|
||||||
const char expected5[] = "A c ;";
|
const char expected5[] = "A c ;";
|
||||||
ASSERT_EQUALS(expected5, tok(code5));
|
ASSERT_EQUALS(expected5, tok(code5));
|
||||||
|
|
||||||
|
// #5614
|
||||||
|
const char code5614[] = "typedef typename T::U V;\n"
|
||||||
|
"typedef typename T::W (V::*Fn)();\n";
|
||||||
|
const char expected5614[] = ";";
|
||||||
|
ASSERT_EQUALS(expected5614, tok(code5614));
|
||||||
}
|
}
|
||||||
|
|
||||||
void simplifyTypedef112() { // ticket #6048
|
void simplifyTypedef112() { // ticket #6048
|
||||||
|
|
Loading…
Reference in New Issue