Ticket #4544: Also handle Foo<struct Bar> constructs.
This commit is contained in:
parent
892f11b7f1
commit
5fd686c878
|
@ -1303,7 +1303,7 @@ bool TemplateSimplifier::simplifyTemplateInstantiations(
|
||||||
typeForPatternMatch += tok3->str();
|
typeForPatternMatch += tok3->str();
|
||||||
}
|
}
|
||||||
// add additional type information
|
// add additional type information
|
||||||
if (!constconst && tok3->str() != "class") {
|
if (!constconst && !Token::Match(tok3, "class|struct|enum")) {
|
||||||
if (tok3->isUnsigned())
|
if (tok3->isUnsigned())
|
||||||
typeForNewName += "unsigned";
|
typeForNewName += "unsigned";
|
||||||
else if (tok3->isSigned())
|
else if (tok3->isSigned())
|
||||||
|
|
|
@ -766,6 +766,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void template37() { // #4544 - A<class B> a;
|
void template37() { // #4544 - A<class B> a;
|
||||||
|
{
|
||||||
const char code[] = "class A { };\n"
|
const char code[] = "class A { };\n"
|
||||||
"template<class T> class B {};\n"
|
"template<class T> class B {};\n"
|
||||||
"B<class A> b1;\n"
|
"B<class A> b1;\n"
|
||||||
|
@ -773,6 +774,23 @@ private:
|
||||||
ASSERT_EQUALS("class A { } ; B < A > b1 ; B < A > b2 ; class B < A > { } ;",
|
ASSERT_EQUALS("class A { } ; B < A > b1 ; B < A > b2 ; class B < A > { } ;",
|
||||||
tok(code));
|
tok(code));
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
const char code[] = "struct A { };\n"
|
||||||
|
"template<class T> class B {};\n"
|
||||||
|
"B<struct A> b1;\n"
|
||||||
|
"B<A> b2;";
|
||||||
|
ASSERT_EQUALS("struct A { } ; B < A > b1 ; B < A > b2 ; class B < A > { } ;",
|
||||||
|
tok(code));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const char code[] = "enum A { };\n"
|
||||||
|
"template<class T> class B {};\n"
|
||||||
|
"B<enum A> b1;\n"
|
||||||
|
"B<A> b2;";
|
||||||
|
ASSERT_EQUALS("enum A { } ; B < A > b1 ; B < A > b2 ; class B < A > { } ;",
|
||||||
|
tok(code));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void template_unhandled() {
|
void template_unhandled() {
|
||||||
// An unhandled template usage should be simplified..
|
// An unhandled template usage should be simplified..
|
||||||
|
|
Loading…
Reference in New Issue