@@ -37,6 +37,7 @@ class TestUnusedFunctions : public TestFixture {
3737 TEST_CASE (incondition);
3838 TEST_CASE (return1);
3939 TEST_CASE (return2);
40+ TEST_CASE (return3);
4041 TEST_CASE (callback1);
4142 TEST_CASE (callback2);
4243 TEST_CASE (else1);
@@ -124,6 +125,24 @@ class TestUnusedFunctions : public TestFixture {
124125 ASSERT_EQUALS (" " , errout.str ());
125126 }
126127
128+ void return3 () {
129+ check (" typedef void (*VoidFunc)();\n " // #9602
130+ " void sayHello() {\n "
131+ " printf(\" Hello World\\ n\" );\n "
132+ " }\n "
133+ " VoidFunc getEventHandler() {\n "
134+ " return sayHello;\n "
135+ " }\n "
136+ " void indirectHello() {\n "
137+ " VoidFunc handler = getEventHandler();\n "
138+ " handler();\n "
139+ " }\n "
140+ " int main() {\n "
141+ " indirectHello();\n "
142+ " }" );
143+ ASSERT_EQUALS (" " , errout.str ());
144+ }
145+
127146 void callback1 () {
128147 check (" void f1()\n "
129148 " {\n "
@@ -314,8 +333,8 @@ class TestUnusedFunctions : public TestFixture {
314333 ASSERT_EQUALS (" " , errout.str ());
315334 }
316335
317- void template9 () { // #7739
318- check (" template<class T>\n "
336+ void template9 () {
337+ check (" template<class T>\n " // #7739
319338 " void f(T const& t) {}\n "
320339 " template<class T>\n "
321340 " void g(T const& t) {\n "
@@ -328,6 +347,12 @@ class TestUnusedFunctions : public TestFixture {
328347 " g(3.14);\n "
329348 " }\n " );
330349 ASSERT_EQUALS (" " , errout.str ());
350+
351+ check (" template <typename T> T f(T);\n " // #9222
352+ " template <typename T> T f(T i) { return i; }\n "
353+ " template int f<int>(int);\n "
354+ " int main() { return f(int(2)); }\n " );
355+ ASSERT_EQUALS (" " , errout.str ());
331356 }
332357
333358 void throwIsNotAFunction () {
0 commit comments