@@ -157,6 +157,7 @@ class TestUnusedVar : public TestFixture {
157157 TEST_CASE (localvarRangeBasedFor); // #7075
158158 TEST_CASE (localvarAssignInWhile);
159159 TEST_CASE (localvarTemplate); // #4955 - variable is used as template parameter
160+ TEST_CASE (localvarFuncPtr); // #7194
160161
161162 TEST_CASE (localvarCppInitialization);
162163 TEST_CASE (localvarCpp11Initialization);
@@ -3885,6 +3886,30 @@ class TestUnusedVar : public TestFixture {
38853886 ASSERT_EQUALS (" " , errout.str ());
38863887 }
38873888
3889+ void localvarFuncPtr () {
3890+ functionVariableUsage (" int main() {\n "
3891+ " void(*funcPtr)(void)(x);\n "
3892+ " }" );
3893+ TODO_ASSERT_EQUALS (" [test.cpp:2]: (style) Variable 'funcPtr' is assigned a value never used.\n " , " " , errout.str ());
3894+
3895+ functionVariableUsage (" int main() {\n "
3896+ " void(*funcPtr)(void);\n "
3897+ " }" );
3898+ ASSERT_EQUALS (" [test.cpp:2]: (style) Unused variable: funcPtr\n " , errout.str ());
3899+
3900+ functionVariableUsage (" int main() {\n "
3901+ " void(*funcPtr)(void)(x);\n "
3902+ " funcPtr();\n "
3903+ " }" );
3904+ ASSERT_EQUALS (" " , errout.str ());
3905+
3906+ functionVariableUsage (" int main() {\n "
3907+ " void(*funcPtr)(void) = x;\n "
3908+ " funcPtr();\n "
3909+ " }" );
3910+ ASSERT_EQUALS (" " , errout.str ());
3911+ }
3912+
38883913 void chainedAssignment () {
38893914 // #5466
38903915 functionVariableUsage (" void NotUsed(double* pdD, int n) {\n "
0 commit comments