diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 5bc08e5ef..15558d341 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -572,6 +572,11 @@ void TemplateSimplifier::useDefaultArgumentValues(const std::list &temp continue; } + if (tok->str() == "(") { // Ticket #6835 + tok = tok->link(); + continue; + } + if (tok->str() == "<" && templateParameters(tok)) ++templateParmDepth; diff --git a/test/testgarbage.cpp b/test/testgarbage.cpp index 247ac8d91..4d5af8b88 100644 --- a/test/testgarbage.cpp +++ b/test/testgarbage.cpp @@ -140,6 +140,7 @@ private: TEST_CASE(garbageCode98); TEST_CASE(garbageCode99); TEST_CASE(garbageCode100); + TEST_CASE(garbageCode101); // #6835 TEST_CASE(garbageValueFlow); TEST_CASE(garbageSymbolDatabase); @@ -791,6 +792,13 @@ private: checkCode("( ) { ( i< ) } int foo ( ) { int i ; ( for ( i => 1 ) ; ) }"); } + void garbageCode101() { // #6835 + // Reported case + checkCode("template < class , =( , int) X = 1 > struct A { } ( ) { = } [ { } ] ( ) { A < void > 0 }"); + // Reduced case + checkCode("template < class =( , ) X = 1> struct A {}; A a;"); + } + void garbageValueFlow() { // #6089 const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"