In this example: ``` //template<std::same_as<int> T> // <= works template<same_as<int> T> // <= didn't work void f() {} ``` the changed line used to match to `< same_as <`, therefore skip creating links. The `%op% %name% <` already feels a bit like a workaround. So adding the condition that $op$ shouldn't be a comparison operator, but part of the template, seemed reasonable to me Co-authored-by: Gerbo Engels <gerbo.engels@ortec-finance.com>
This commit is contained in:
parent
2ac9fbc1bf
commit
221873e69f
|
@ -4702,7 +4702,7 @@ void Tokenizer::createLinks2()
|
||||||
} else {
|
} else {
|
||||||
type.pop();
|
type.pop();
|
||||||
if (Token::Match(token, "> %name%") && !token->next()->isKeyword() &&
|
if (Token::Match(token, "> %name%") && !token->next()->isKeyword() &&
|
||||||
Token::Match(top1->tokAt(-2), "%op% %name% <") &&
|
Token::Match(top1->tokAt(-2), "%op% %name% <") && top1->strAt(-2) != "<" &&
|
||||||
(templateTokens.empty() || top1 != templateTokens.top()))
|
(templateTokens.empty() || top1 != templateTokens.top()))
|
||||||
continue;
|
continue;
|
||||||
Token::createMutualLinks(top1, token);
|
Token::createMutualLinks(top1, token);
|
||||||
|
|
|
@ -3250,6 +3250,20 @@ private:
|
||||||
ASSERT(nullptr == Token::findsimplematch(tokenizer.tokens(), "<")->link());
|
ASSERT(nullptr == Token::findsimplematch(tokenizer.tokens(), "<")->link());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// #11319
|
||||||
|
const char code[] = "using std::same_as;\n"
|
||||||
|
"template<same_as<int> T>\n"
|
||||||
|
"void f();";
|
||||||
|
Tokenizer tokenizer(&settings0, this);
|
||||||
|
std::istringstream istr(code);
|
||||||
|
ASSERT(tokenizer.tokenize(istr, "test.cpp"));
|
||||||
|
const Token *tok1 = Token::findsimplematch(tokenizer.tokens(), "template <");
|
||||||
|
const Token *tok2 = Token ::findsimplematch(tokenizer.tokens(), "same_as <");
|
||||||
|
ASSERT(tok1->next()->link() == tok1->tokAt(7));
|
||||||
|
ASSERT(tok2->next()->link() == tok2->tokAt(3));
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// #9131 - template usage or comparison?
|
// #9131 - template usage or comparison?
|
||||||
const char code[] = "using std::list; list<t *> l;";
|
const char code[] = "using std::list; list<t *> l;";
|
||||||
|
|
Loading…
Reference in New Issue