File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2043,7 +2043,7 @@ void TemplateSimplifier::expandTemplate(
20432043 addNamespace (templateDeclaration, tok3);
20442044 }
20452045 mTokenList .addtoken (newName, tok3);
2046- } else if (!Token::Match (tok3->next (), " :|{|=" ))
2046+ } else if (!Token::Match (tok3->next (), " :|{|=|; " ))
20472047 tok3->str (newName);
20482048 continue ;
20492049 }
Original file line number Diff line number Diff line change @@ -189,6 +189,7 @@ class TestSimplifyTemplate : public TestFixture {
189189 TEST_CASE (template149); // unknown macro
190190 TEST_CASE (template150); // syntax error
191191 TEST_CASE (template151); // crash
192+ TEST_CASE (template152); // #9467
192193 TEST_CASE (template_specialization_1); // #7868 - template specialization template <typename T> struct S<C<T>> {..};
193194 TEST_CASE (template_specialization_2); // #7868 - template specialization template <typename T> struct S<C<T>> {..};
194195 TEST_CASE (template_enum); // #6299 Syntax error in complex enum declaration (including template)
@@ -3619,6 +3620,38 @@ class TestSimplifyTemplate : public TestFixture {
36193620 }
36203621 }
36213622
3623+ void template152 () { // #9467
3624+ const char code[] = " class Foo {\n "
3625+ " template <unsigned int i>\n "
3626+ " bool bar() {\n "
3627+ " return true;\n "
3628+ " }\n "
3629+ " };\n "
3630+ " template <>\n "
3631+ " bool Foo::bar<9>() {\n "
3632+ " return true;\n "
3633+ " }\n "
3634+ " int global() {\n "
3635+ " int bar = 1;\n "
3636+ " return bar;\n "
3637+ " }" ;
3638+ const char exp[] = " class Foo { "
3639+ " bool bar<9> ( ) ; "
3640+ " template < unsigned int i > "
3641+ " bool bar ( ) { "
3642+ " return true ; "
3643+ " } "
3644+ " } ; "
3645+ " bool Foo :: bar<9> ( ) { "
3646+ " return true ; "
3647+ " } "
3648+ " int global ( ) { "
3649+ " int bar ; bar = 1 ; "
3650+ " return bar ; "
3651+ " }" ;
3652+ ASSERT_EQUALS (exp, tok (code));
3653+ }
3654+
36223655 void template_specialization_1 () { // #7868 - template specialization template <typename T> struct S<C<T>> {..};
36233656 const char code[] = " template <typename T> struct C {};\n "
36243657 " template <typename T> struct S {a};\n "
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ class TestUninitVar : public TestFixture {
6969 TEST_CASE (uninitvar2_malloc); // malloc returns uninitialized data
7070 TEST_CASE (uninitvar8); // ticket #6230
7171 TEST_CASE (uninitvar9); // ticket #6424
72+ TEST_CASE (uninitvar10); // ticket #9467
7273 TEST_CASE (uninitvar_unconditionalTry);
7374 TEST_CASE (uninitvar_funcptr); // #6404
7475 TEST_CASE (uninitvar_operator); // #6680
@@ -2664,6 +2665,25 @@ class TestUninitVar : public TestFixture {
26642665 " [test.cpp:4]: (error) Uninitialized variable: p\n " , errout.str ());
26652666 }
26662667
2668+ void uninitvar10 () { // 9467
2669+ const char code[] = " class Foo {\n "
2670+ " template <unsigned int i>\n "
2671+ " bool bar() {\n "
2672+ " return true;\n "
2673+ " }\n "
2674+ " };\n "
2675+ " template <>\n "
2676+ " bool Foo::bar<9>() {\n "
2677+ " return true;\n "
2678+ " }\n "
2679+ " int global() {\n "
2680+ " int bar = 1;\n "
2681+ " return bar;\n "
2682+ " }" ;
2683+ checkUninitVar (code, " test.cpp" );
2684+ ASSERT_EQUALS (" " , errout.str ());
2685+ }
2686+
26672687 void uninitvar_unconditionalTry () {
26682688 // Unconditional scopes and try{} scopes
26692689 checkUninitVar (" int f() {\n "
You can’t perform that action at this time.
0 commit comments