Fixed #4002 (syntax error for 'X( typedef, Y)')
This commit is contained in:
parent
69a0062177
commit
0c55d5cfa7
|
@ -527,6 +527,12 @@ void Tokenizer::simplifyTypedef()
|
|||
tok = tok->previous();
|
||||
}
|
||||
|
||||
// Skip typedefs inside parentheses (#2453 and #4002)
|
||||
if (tok->str() == "(" && tok->strAt(1) == "typedef") {
|
||||
tok = tok->next();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Token::Match(tok, "class|struct|namespace %any%") &&
|
||||
(!tok->previous() || (tok->previous() && tok->previous()->str() != "enum"))) {
|
||||
isNamespace = (tok->str() == "namespace");
|
||||
|
@ -551,12 +557,6 @@ void Tokenizer::simplifyTypedef()
|
|||
} else if (tok->str() != "typedef")
|
||||
continue;
|
||||
|
||||
// check for syntax errors
|
||||
if (tok->previous() && tok->previous()->str() == "(") {
|
||||
syntaxError(tok);
|
||||
continue;
|
||||
}
|
||||
|
||||
// pull struct, union, enum or class definition out of typedef
|
||||
// use typedef name for unnamed struct, union, enum or class
|
||||
if (Token::Match(tok->next(), "const| struct|enum|union|class %type% {") ||
|
||||
|
|
|
@ -5382,7 +5382,7 @@ private:
|
|||
const char code[] = "void f1(typedef int x) {}\n";
|
||||
const std::string expected = "void f1 ( typedef int x ) { }";
|
||||
ASSERT_EQUALS(expected, tok(code));
|
||||
ASSERT_EQUALS("[test.cpp:1]: (error) syntax error\n", errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedef77() { // ticket #2554
|
||||
|
|
Loading…
Reference in New Issue