Fixed #9084 (Tokenizer::setVarId: Same varid for member variable and argument, unknown template type)
This commit is contained in:
parent
4d9b1e6c3d
commit
27fad38e00
|
@ -2875,15 +2875,15 @@ static bool setVarIdParseDeclaration(const Token **tok, const std::map<std::stri
|
|||
const Token *start = *tok;
|
||||
if (Token::Match(start->previous(), "%or%|%oror%|&&|&|^|+|-|*|/"))
|
||||
return false;
|
||||
const Token * tok3 = tok2->findClosingBracket();
|
||||
if (tok3 == nullptr) { /* Ticket #8151 */
|
||||
const Token * const closingBracket = tok2->findClosingBracket();
|
||||
if (closingBracket == nullptr) { /* Ticket #8151 */
|
||||
throw tok2;
|
||||
}
|
||||
tok2 = tok3;
|
||||
tok2 = closingBracket;
|
||||
if (tok2->str() != ">")
|
||||
break;
|
||||
singleNameCount = 1;
|
||||
if (Token::Match(tok2, "> %name% %or%|%oror%|&&|&|^|+|-|*|/"))
|
||||
if (Token::Match(tok2, "> %name% %or%|%oror%|&&|&|^|+|-|*|/") && !Token::Match(tok2, "> const [*&]"))
|
||||
return false;
|
||||
if (Token::Match(tok2, "> %name% )")) {
|
||||
if (Token::Match(tok2->linkAt(2)->previous(), "if|for|while ("))
|
||||
|
|
|
@ -93,6 +93,7 @@ private:
|
|||
TEST_CASE(varid60); // #7267 cast '(unsigned x)10'
|
||||
TEST_CASE(varid61); // #4988 inline function
|
||||
TEST_CASE(varid62);
|
||||
TEST_CASE(varid63);
|
||||
TEST_CASE(varid_cpp_keywords_in_c_code);
|
||||
TEST_CASE(varid_cpp_keywords_in_c_code2); // #5373: varid=0 for argument called "delete"
|
||||
TEST_CASE(varidFunctionCall1);
|
||||
|
@ -1115,6 +1116,12 @@ private:
|
|||
ASSERT_EQUALS("same varid", compareVaridsForVariable(code, "x"));
|
||||
}
|
||||
|
||||
void varid63() {
|
||||
const char code[] = "void f(boost::optional<int> const& x) {}";
|
||||
const char expected[] = "1: void f ( boost :: optional < int > const & x@1 ) { }\n";
|
||||
ASSERT_EQUALS(expected, tokenize(code, false));
|
||||
}
|
||||
|
||||
void varid_cpp_keywords_in_c_code() {
|
||||
const char code[] = "void f() {\n"
|
||||
" delete d;\n"
|
||||
|
|
Loading…
Reference in New Issue