File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -557,6 +557,8 @@ void TemplateSimplifier::useDefaultArgumentValues(const std::list<Token *> &temp
557557 for (Token *tok = *iter1; tok; tok = tok->next ()) {
558558 if (Token::simpleMatch (tok, " template < >" )) { // Ticket #5762: Skip specialization tokens
559559 tok = tok->tokAt (2 );
560+ if (0 == templateParmDepth)
561+ break ;
560562 continue ;
561563 }
562564
@@ -638,7 +640,11 @@ void TemplateSimplifier::useDefaultArgumentValues(const std::list<Token *> &temp
638640 Token *tok2;
639641 int indentlevel = 0 ;
640642 for (tok2 = eqtok->next (); tok2; tok2 = tok2->next ()) {
641- if (tok2->str () == " (" )
643+ if (Token::Match (tok2, " ;|)|}|]" )) { // bail out #6607
644+ tok2 = nullptr ;
645+ break ;
646+ }
647+ if (Token::Match (tok2, " (|{|[" ))
642648 tok2 = tok2->link ();
643649 else if (Token::Match (tok2, " %type% <" ) && templateParameters (tok2->next ())) {
644650 std::list<Token*>::iterator ti = std::find (templateInstantiations->begin (),
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ class TestGarbage : public TestFixture {
7474 TEST_CASE (garbageCode33); // #6613
7575 TEST_CASE (garbageCode34); // #6626
7676 TEST_CASE (garbageCode35); // #2599, #2604
77+ TEST_CASE (garbageCode36); // #6334
7778
7879 TEST_CASE (garbageValueFlow);
7980 TEST_CASE (garbageSymbolDatabase);
@@ -543,6 +544,15 @@ class TestGarbage : public TestFixture {
543544 " }\n "
544545 );
545546 }
547+
548+ void garbageCode36 () { // #6334
549+ checkCode (" { } < class template < > , { = } ; class... >\n "
550+ " struct Y { }\n "
551+ " class Types { }\n "
552+ " ( X < int > \" uses template\" ) ( < ( ) \" uses ; \n "
553+ " ( int int ::primary \" uses template\" ) int double \" uses )\n "
554+ " ::primary , \" uses template\" ;\n " );
555+ }
546556};
547557
548558REGISTER_TEST (TestGarbage)
You can’t perform that action at this time.
0 commit comments