Fixed #4445 (Token::Match called with varid 0)
This commit is contained in:
parent
e09dfadce6
commit
dfed6bbea0
|
@ -234,6 +234,7 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name, const Token
|
||||||
} else {
|
} else {
|
||||||
// look backwards
|
// look backwards
|
||||||
if (Token::Match(tok->previous(), "typedef|}|>") ||
|
if (Token::Match(tok->previous(), "typedef|}|>") ||
|
||||||
|
(end->str() == ";" && tok->previous()->str() == ",") ||
|
||||||
(tok->previous()->str() == "*" && tok->next()->str() != "(") ||
|
(tok->previous()->str() == "*" && tok->next()->str() != "(") ||
|
||||||
(Token::Match(tok->previous(), "%type%") &&
|
(Token::Match(tok->previous(), "%type%") &&
|
||||||
(!Token::Match(tok->previous(), "return|new|const|friend|public|private|protected|throw|extern") &&
|
(!Token::Match(tok->previous(), "return|new|const|friend|public|private|protected|throw|extern") &&
|
||||||
|
|
|
@ -308,6 +308,8 @@ private:
|
||||||
TEST_CASE(simplifyTypedefFunction7);
|
TEST_CASE(simplifyTypedefFunction7);
|
||||||
TEST_CASE(simplifyTypedefFunction8);
|
TEST_CASE(simplifyTypedefFunction8);
|
||||||
|
|
||||||
|
TEST_CASE(simplifyTypedefShadow); // #4445 - shadow variable
|
||||||
|
|
||||||
TEST_CASE(simplifyOperator1);
|
TEST_CASE(simplifyOperator1);
|
||||||
|
|
||||||
TEST_CASE(reverseArraySyntax)
|
TEST_CASE(reverseArraySyntax)
|
||||||
|
@ -6573,6 +6575,15 @@ private:
|
||||||
TODO_ASSERT_EQUALS("", "[test.cpp:2]: (debug) Function::addArguments found argument 'int' with varid 0.\n", errout.str()); // make sure that there is no internal error
|
TODO_ASSERT_EQUALS("", "[test.cpp:2]: (debug) Function::addArguments found argument 'int' with varid 0.\n", errout.str()); // make sure that there is no internal error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void simplifyTypedefShadow() { // shadow variable (#4445)
|
||||||
|
const char code[] = "typedef struct { int x; } xyz;;\n"
|
||||||
|
"void f(){\n"
|
||||||
|
" int abc, xyz;\n" // <- shadow variable
|
||||||
|
"}\n";
|
||||||
|
ASSERT_EQUALS("struct xyz { int x ; } ; void f ( ) { int abc ; int xyz ; }",
|
||||||
|
tok(code,false));
|
||||||
|
}
|
||||||
|
|
||||||
void simplifyOperator1() {
|
void simplifyOperator1() {
|
||||||
// #3237 - error merging namespaces with operators
|
// #3237 - error merging namespaces with operators
|
||||||
const char code[] = "class c {\n"
|
const char code[] = "class c {\n"
|
||||||
|
|
Loading…
Reference in New Issue