Fixed #6190 (SymbolDatabase: variable info not set properly when reinterpret_cast is used)
This commit is contained in:
parent
11867e3210
commit
77cffcde38
|
@ -2695,6 +2695,9 @@ bool Scope::isVariableDeclaration(const Token* tok, const Token*& vartok, const
|
|||
const Token* localVarTok = nullptr;
|
||||
|
||||
if (Token::Match(localTypeTok, "%type% <")) {
|
||||
if (Token::Match(tok, "const_cast|dynamic_cast|reinterpret_cast|static_cast <"))
|
||||
return false;
|
||||
|
||||
const Token* closeTok = localTypeTok->next()->link();
|
||||
if (closeTok) {
|
||||
localVarTok = skipPointers(closeTok->next());
|
||||
|
|
|
@ -128,6 +128,7 @@ private:
|
|||
TEST_CASE(isVariableDeclarationIdentifiesNestedTemplateVariable);
|
||||
TEST_CASE(isVariableDeclarationIdentifiesReference);
|
||||
TEST_CASE(isVariableDeclarationDoesNotIdentifyTemplateClass);
|
||||
TEST_CASE(isVariableDeclarationDoesNotIdentifyCppCast);
|
||||
TEST_CASE(isVariableDeclarationPointerConst);
|
||||
TEST_CASE(isVariableDeclarationRValueRef);
|
||||
TEST_CASE(isVariableStlType);
|
||||
|
@ -603,6 +604,13 @@ private:
|
|||
ASSERT_EQUALS(false, result);
|
||||
}
|
||||
|
||||
void isVariableDeclarationDoesNotIdentifyCppCast() {
|
||||
reset();
|
||||
givenACodeSampleToTokenize var("reinterpret_cast <char *> (code)[0] = 0;");
|
||||
bool result = si.isVariableDeclaration(var.tokens(), vartok, typetok);
|
||||
ASSERT_EQUALS(false, result);
|
||||
}
|
||||
|
||||
void isVariableDeclarationPointerConst() {
|
||||
reset();
|
||||
givenACodeSampleToTokenize var("std::string const* s;");
|
||||
|
|
Loading…
Reference in New Issue