diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index 7124dfc09..f0e3045c1 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -73,6 +73,7 @@ private: TEST_CASE(localvar8); TEST_CASE(localvar9); // ticket #1605 TEST_CASE(localvar10); + TEST_CASE(localvaralias); TEST_CASE(localvarasm); // Don't give false positives for variables in structs/unions @@ -640,6 +641,26 @@ private: "[test.cpp:7]: (style) Unused variable: i\n", errout.str()); } + void localvaralias() + { + functionVariableUsage("void foo()\n" + "{\n" + " int a;\n" + " int *b = &a;\n" + " *b = 0;\n" + "}\n"); + ASSERT_EQUALS(std::string(""), errout.str()); + + functionVariableUsage("void foo()\n" + "{\n" + " int a[10];\n" + " int *b = a;\n" + " *b = 0;\n" + "}\n"); + ASSERT_EQUALS(std::string("[test.cpp:3]: (style) Variable 'a' is not assigned a value\n"), errout.str()); + TODO_ASSERT_EQUALS(std::string(""), errout.str()); + } + void localvarasm() { functionVariableUsage("void foo(int &b)\n"