Fixed #7865 (Tokenizer::createLinks2(): does does set links for <> in struct template)
This commit is contained in:
parent
8aab4371e8
commit
4c25e798b1
|
@ -3035,7 +3035,7 @@ void Tokenizer::createLinks2()
|
|||
|
||||
std::stack<Token*> type;
|
||||
for (Token *token = list.front(); token; token = token->next()) {
|
||||
if (Token::Match(token, "struct|class %name% :"))
|
||||
if (Token::Match(token, "struct|class %name% [:<]"))
|
||||
isStruct = true;
|
||||
else if (Token::Match(token, "[;{}]"))
|
||||
isStruct = false;
|
||||
|
|
|
@ -4531,6 +4531,21 @@ private:
|
|||
ASSERT_EQUALS(true, tok->link() == tok->tokAt(4));
|
||||
ASSERT_EQUALS(true, tok->linkAt(4) == tok);
|
||||
}
|
||||
|
||||
{
|
||||
// #7865
|
||||
const char code[] = "template <typename T, typename U>\n"
|
||||
"struct CheckedDivOp< T, U, typename std::enable_if<std::is_floating_point<T>::value || std::is_floating_point<U>::value>::type> {\n"
|
||||
"};\n";
|
||||
errout.str("");
|
||||
Tokenizer tokenizer(&settings0, this);
|
||||
std::istringstream istr(code);
|
||||
tokenizer.tokenize(istr, "test.cpp");
|
||||
const Token *tok1 = Token::findsimplematch(tokenizer.tokens(), "struct")->tokAt(2);
|
||||
const Token *tok2 = Token::findsimplematch(tokenizer.tokens(), "{")->previous();
|
||||
ASSERT_EQUALS(true, tok1->link() == tok2);
|
||||
ASSERT_EQUALS(true, tok2->link() == tok1);
|
||||
}
|
||||
}
|
||||
|
||||
void simplifyString() {
|
||||
|
|
Loading…
Reference in New Issue