@@ -310,7 +310,7 @@ class TestSimplifyTemplate : public TestFixture {
310310 // The expected result..
311311 const char expected[] = " void f ( ) { A < int > a ; } "
312312 " template < typename T > class B { void g ( ) { A < T > b ; b = A < T > :: h ( ) ; } } ; "
313- " class A < int > { } ; class A < T > { } ; " ;
313+ " class A < int > { } ;" ;
314314
315315 ASSERT_EQUALS (expected, tok (code));
316316 }
@@ -473,7 +473,6 @@ class TestSimplifyTemplate : public TestFixture {
473473
474474 const char expected[] = " int main ( ) { b < 2 > ( ) ; return 0 ; } "
475475 " void b < 2 > ( ) { a < 2 > ( ) ; } "
476- " void a < i > ( ) { } "
477476 " void a < 2 > ( ) { }" ;
478477
479478 ASSERT_EQUALS (expected, tok (code));
@@ -722,7 +721,6 @@ class TestSimplifyTemplate : public TestFixture {
722721 ASSERT_EQUALS (" C < int > c ; "
723722 " struct C < int > { A < B < X < int > > > ab ; } ; "
724723 " struct B < X < int > > { } ; " // <- redundant.. but nevermind
725- " struct A < B < X < T > > > { } ; " // <- redundant.. but nevermind
726724 " struct A < B < X < int > > > { } ;" , tok (code));
727725 }
728726
@@ -912,11 +910,12 @@ class TestSimplifyTemplate : public TestFixture {
912910 " template < class T > void Fred < T > :: g ( ) { } "
913911 " template void Fred < float > :: f ( ) ; "
914912 " template void Fred < int > :: g ( ) ; "
915- " class Fred < T > { void f ( ) ; void g ( ) ; } ; "
916- " Fred < T > :: f ( ) { } "
917- " Fred < T > :: g ( ) { } "
918913 " class Fred < float > { void f ( ) ; void g ( ) ; } ; "
919- " class Fred < int > { void f ( ) ; void g ( ) ; } ;" ;
914+ " Fred < float > :: f ( ) { } "
915+ " Fred < float > :: g ( ) { } "
916+ " class Fred < int > { void f ( ) ; void g ( ) ; } ; "
917+ " Fred < int > :: f ( ) { } "
918+ " Fred < int > :: g ( ) { }" ;
920919
921920 ASSERT_EQUALS (expected, tok (code));
922921 }
@@ -927,13 +926,10 @@ class TestSimplifyTemplate : public TestFixture {
927926 " template<> void Fred<float>::f() { }\n "
928927 " template<> void Fred<int>::g() { }\n " ;
929928
930- const char expected[] = " template < class T > void Fred < T > :: f ( ) { } "
929+ const char expected[] = " template < class T > class Fred { void f ( ) ; } ; "
930+ " template < class T > void Fred < T > :: f ( ) { } "
931931 " template < > void Fred < float > :: f ( ) { } "
932- " template < > void Fred < int > :: g ( ) { } "
933- " class Fred < T > { void f ( ) ; } ; "
934- " Fred < T > :: f ( ) { } "
935- " class Fred < float > { void f ( ) ; } ; "
936- " class Fred < int > { void f ( ) ; } ;" ;
932+ " template < > void Fred < int > :: g ( ) { }" ;
937933
938934 ASSERT_EQUALS (expected, tok (code));
939935 }
@@ -982,13 +978,10 @@ class TestSimplifyTemplate : public TestFixture {
982978 void template55 () { // #6604
983979 // Avoid constconstconst in macro instantiations
984980 ASSERT_EQUALS (
985- " class AtSmartPtr < T > : public ConstCastHelper < AtSmartPtr < const T > , T > { "
981+ " template < class T > class AtSmartPtr : public ConstCastHelper < AtSmartPtr < const T > , T > { "
986982 " friend struct ConstCastHelper < AtSmartPtr < const T > , T > ; "
987- " AtSmartPtr < T > ( const AtSmartPtr < T > & r ) ; "
988- " } ; "
989- " class AtSmartPtr < const T > : public ConstCastHelper < AtSmartPtr < const const T > , const T > { "
990- " friend struct ConstCastHelper < AtSmartPtr < const const T > , const T > ; "
991- " AtSmartPtr < const T > ( const AtSmartPtr < T > & r ) ; } ;" ,
983+ " AtSmartPtr ( const AtSmartPtr < T > & r ) ; "
984+ " } ;" ,
992985 tok (" template<class T> class AtSmartPtr : public ConstCastHelper<AtSmartPtr<const T>, T>\n "
993986 " {\n "
994987 " friend struct ConstCastHelper<AtSmartPtr<const T>, T>;\n "
@@ -1062,17 +1055,12 @@ class TestSimplifyTemplate : public TestFixture {
10621055 " enum {value = !type_equal<T, typename Unconst<T>::type>::value };\n "
10631056 " };" ;
10641057 const char exp1[] = " template < class T > struct Unconst { } ; "
1058+ " template < class T > struct Unconst < const T > { } ; "
1059+ " template < class T > struct Unconst < const T & > { } ; "
1060+ " template < class T > struct Unconst < T * const > { } ; "
1061+ " template < class T1 , class T2 > struct type_equal { enum Anonymous0 { value = 0 } ; } ; "
10651062 " template < class T > struct type_equal < T , T > { enum Anonymous1 { value = 1 } ; } ; "
1066- " template < class T > struct template_is_const { enum Anonymous2 { value = ! type_equal < T , Unconst < T > :: type > :: value } ; } ; "
1067- " struct type_equal < T , T > { enum Anonymous0 { value = 0 } ; } ; "
1068- " struct Unconst < const T * const > { } ; "
1069- " struct Unconst < const T & * const > { } ; "
1070- " struct Unconst < T * const * const > { } ; "
1071- " struct Unconst < T * const > { } ; "
1072- " struct Unconst < T * const > { } ; "
1073- " struct Unconst < T * const > { } ; "
1074- " struct Unconst < const T & > { } ; "
1075- " struct Unconst < const T > { } ;" ;
1063+ " template < class T > struct template_is_const { enum Anonymous2 { value = ! type_equal < T , Unconst < T > :: type > :: value } ; } ;" ;
10761064 ASSERT_EQUALS (exp1, tok (code1));
10771065 }
10781066
@@ -1346,6 +1334,10 @@ class TestSimplifyTemplate : public TestFixture {
13461334 ASSERT_EQUALS (3U , templateParameters (" X<char, int(*)(), bool> x;" ));
13471335 TODO_ASSERT_EQUALS (1U , 0U , templateParameters (" X<int...> x;" )); // Mishandled valid syntax
13481336 TODO_ASSERT_EQUALS (2U , 0U , templateParameters (" X<class, typename...> x;" )); // Mishandled valid syntax
1337+ ASSERT_EQUALS (2U , templateParameters (" X<1, T> x;" ));
1338+ ASSERT_EQUALS (1U , templateParameters (" X<i == 0> x;" ));
1339+ ASSERT_EQUALS (2U , templateParameters (" X<int, i>=0> x;" ));
1340+ ASSERT_EQUALS (3U , templateParameters (" X<int, i>=0, i - 2> x;" ));
13491341 }
13501342
13511343 // Helper function to unit test TemplateSimplifier::getTemplateNamePosition
0 commit comments