Ticket #6835: Don't get confused by parentheses while detecting template parameter default values.

This commit is contained in:
Simon Martin 2015-07-17 21:30:34 +02:00
parent 25d9ebedd8
commit af1b0cfddf
2 changed files with 13 additions and 0 deletions

View File

@ -572,6 +572,11 @@ void TemplateSimplifier::useDefaultArgumentValues(const std::list<Token *> &temp
continue;
}
if (tok->str() == "(") { // Ticket #6835
tok = tok->link();
continue;
}
if (tok->str() == "<" && templateParameters(tok))
++templateParmDepth;

View File

@ -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<void> a;");
}
void garbageValueFlow() {
// #6089
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"