diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index b2108d2d515..0c17319c656 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -554,7 +554,7 @@ void bufferAccessOutOfBounds_std_ifstream_get(std::ifstream& in, std::streambuf& in.getline(cBuf, 100, 'a'); in.get(sb, 'a'); - + in.close(); } diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 66faadff3fd..62ca87d0311 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -4350,6 +4350,28 @@ class TestUninitVar : public TestFixture { " f(i);\n" "}"); ASSERT_EQUALS("", errout_str()); + + valueFlowUninit("int f(int& i, int j, int k) {\n" // #12514 + " if (k)\n" + " i = 2;\n" + " return i + j;\n" + "}\n" + "int main() {\n" + " int i;\n" + " return f(i, 1, 0);\n" + "}"); + ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:4]: (warning) Uninitialized variable: i\n", errout_str()); + + valueFlowUninit("int f(int& i, int k) {\n" + " if (k)\n" + " i = 2;\n" + " return i;\n" + "}\n" + "int main() {\n" + " int i;\n" + " return f(i, 0);\n" + "}"); + ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:4]: (warning) Uninitialized variable: i\n", errout_str()); } void uninitStructMember() { // struct members diff --git a/tools/defines/float.c b/tools/defines/float.c index 1d53f818510..31887414740 100644 --- a/tools/defines/float.c +++ b/tools/defines/float.c @@ -2,7 +2,7 @@ #include "stdio.h" #define PRINT_DEF(d, f) \ - fprintf(stdout, ";"#d"=%"#f, d) + fprintf(stdout, ";"#d "=%"#f, d) int main(void) { diff --git a/tools/defines/limits.c b/tools/defines/limits.c index 8f2d9c90a7d..0407aefac22 100644 --- a/tools/defines/limits.c +++ b/tools/defines/limits.c @@ -2,7 +2,7 @@ #include "stdio.h" #define PRINT_DEF(d, f) \ - fprintf(stdout, ";"#d"=%"#f, d) + fprintf(stdout, ";"#d "=%"#f, d) int main(void) { diff --git a/tools/defines/stdint.c b/tools/defines/stdint.c index bd899140de2..72fc6c6ead8 100644 --- a/tools/defines/stdint.c +++ b/tools/defines/stdint.c @@ -2,7 +2,7 @@ #include "stdio.h" #define PRINT_DEF(d, f) \ - fprintf(stdout, ";"#d"=%"#f, d) + fprintf(stdout, ";"#d "=%"#f, d) #define PRINT_DEF_N(d1, d2, f) \ do { \ @@ -40,5 +40,5 @@ int main(void) PRINT_DEF(WINT_MIN, d); PRINT_DEF(WINT_MAX, d); - return 0; + return 0; }