File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -5250,7 +5250,8 @@ void Tokenizer::createLinks2()
52505250 } else if (token->str () == " <" &&
52515251 ((token->previous () && (token->previous ()->isTemplate () ||
52525252 (token->previous ()->isName () && !token->previous ()->varId ()) ||
5253- (token->strAt (-1 ) == " ]" && (!Token::Match (token->linkAt (-1 )->previous (), " %name%|)" ) || token->linkAt (-1 )->previous ()->isKeyword ())))) ||
5253+ (token->strAt (-1 ) == " ]" && (!Token::Match (token->linkAt (-1 )->previous (), " %name%|)" ) || token->linkAt (-1 )->previous ()->isKeyword ())) ||
5254+ (token->strAt (-1 ) == " )" && token->linkAt (-1 )->strAt (-1 ) == " operator" ))) ||
52545255 Token::Match (token->next (), " >|>>" ))) {
52555256 type.push (token);
52565257 if (token->previous ()->str () == " template" )
Original file line number Diff line number Diff line change @@ -3531,6 +3531,25 @@ class TestTokenizer : public TestFixture {
35313531 ASSERT_EQUALS (true , tok1->link () == tok2);
35323532 ASSERT_EQUALS (true , tok2->link () == tok1);
35333533 }
3534+
3535+ {
3536+ const char code[] = " struct S {\n " // #11840
3537+ " template<typename T, typename U>\n "
3538+ " void operator() (int);\n "
3539+ " };\n "
3540+ " void f() {\n "
3541+ " S s;\n "
3542+ " s.operator()<int, int>(1);\n "
3543+ " }\n " ;
3544+ errout.str (" " );
3545+ Tokenizer tokenizer (&settings0, this );
3546+ std::istringstream istr (code);
3547+ ASSERT (tokenizer.tokenize (istr, " test.cpp" ));
3548+ const Token* tok1 = Token::findsimplematch (tokenizer.tokens (), " < int" );
3549+ const Token* tok2 = Token::findsimplematch (tok1, " > (" );
3550+ ASSERT_EQUALS (true , tok1->link () == tok2);
3551+ ASSERT_EQUALS (true , tok2->link () == tok1);
3552+ }
35343553 }
35353554
35363555 void simplifyString () {
You can’t perform that action at this time.
0 commit comments