diff --git a/test/testio.cpp b/test/testio.cpp index 7e364422a..8e2c4e807 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -697,369 +697,621 @@ private: "}", true); ASSERT_EQUALS("", errout.str()); - check("const unsigned int * foo() { }\n" - "void foo() {\n" - " bool b;\n" - " char c;\n" - " signed char sc;\n" - " unsigned char uc;\n" - " short s;\n" - " unsigned short us;\n" - " int i;\n" - " unsigned int ui;\n" - " long l;\n" - " unsigned long ul;\n" - " long long ll;\n" - " unsigned long long ull;\n" - " float f;\n" - " double d;\n" - " long double ld;\n" - " size_t st;\n" - " ptrdiff_t pt;\n" - " intmax_t it;\n" - " uintmax_t ut;\n" - " void * vp;\n" - " scanf(\"%u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u\",\n" - " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, \"str\", L\"str\", foo(), &unknown, unknown);\n" - "}\n", true); - ASSERT_EQUALS("[test.cpp:23]: (warning) %u in format string (no. 1) requires 'unsigned int *' but the argument type is 'bool *'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 2) requires 'unsigned int *' but the argument type is 'char *'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 3) requires 'unsigned int *' but the argument type is 'signed char *'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 4) requires 'unsigned int *' but the argument type is 'unsigned char *'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 5) requires 'unsigned int *' but the argument type is 'short *'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 6) requires 'unsigned int *' but the argument type is 'unsigned short *'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 7) requires 'unsigned int *' but the argument type is 'int *'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 9) requires 'unsigned int *' but the argument type is 'long *'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 10) requires 'unsigned int *' but the argument type is 'unsigned long *'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 11) requires 'unsigned int *' but the argument type is 'long long *'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 12) requires 'unsigned int *' but the argument type is 'unsigned long long *'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 13) requires 'unsigned int *' but the argument type is 'float *'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 14) requires 'unsigned int *' but the argument type is 'double *'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 15) requires 'unsigned int *' but the argument type is 'long double *'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 16) requires 'unsigned int *' but the argument type is 'size_t * {aka unsigned long *}'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 17) requires 'unsigned int *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 18) requires 'unsigned int *' but the argument type is 'intmax_t * {aka long *}'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 19) requires 'unsigned int *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 20) requires 'unsigned int *' but the argument type is 'void * *'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 21) requires 'unsigned int *' but the argument type is 'void *'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 22) requires 'unsigned int *' but the argument type is 'const char *'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 23) requires 'unsigned int *' but the argument type is 'const wchar_t *'.\n" - "[test.cpp:23]: (warning) %u in format string (no. 24) requires 'unsigned int *' but the argument type is 'const unsigned int *'.\n", errout.str()); + { + const char * code = "const unsigned int * foo() { }\n" + "void foo() {\n" + " bool b;\n" + " char c;\n" + " signed char sc;\n" + " unsigned char uc;\n" + " short s;\n" + " unsigned short us;\n" + " int i;\n" + " unsigned int ui;\n" + " long l;\n" + " unsigned long ul;\n" + " long long ll;\n" + " unsigned long long ull;\n" + " float f;\n" + " double d;\n" + " long double ld;\n" + " size_t st;\n" + " ptrdiff_t pt;\n" + " intmax_t it;\n" + " uintmax_t ut;\n" + " void * vp;\n" + " scanf(\"%u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u\",\n" + " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, \"str\", L\"str\", foo(), &unknown, unknown);\n" + "}\n"; + std::string result("[test.cpp:23]: (warning) %u in format string (no. 1) requires 'unsigned int *' but the argument type is 'bool *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 2) requires 'unsigned int *' but the argument type is 'char *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 3) requires 'unsigned int *' but the argument type is 'signed char *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 4) requires 'unsigned int *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 5) requires 'unsigned int *' but the argument type is 'short *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 6) requires 'unsigned int *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 7) requires 'unsigned int *' but the argument type is 'int *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 9) requires 'unsigned int *' but the argument type is 'long *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 10) requires 'unsigned int *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 11) requires 'unsigned int *' but the argument type is 'long long *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 12) requires 'unsigned int *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 13) requires 'unsigned int *' but the argument type is 'float *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 14) requires 'unsigned int *' but the argument type is 'double *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 15) requires 'unsigned int *' but the argument type is 'long double *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 16) requires 'unsigned int *' but the argument type is 'size_t * {aka unsigned long *}'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 17) requires 'unsigned int *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 18) requires 'unsigned int *' but the argument type is 'intmax_t * {aka long *}'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 19) requires 'unsigned int *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 20) requires 'unsigned int *' but the argument type is 'void * *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 21) requires 'unsigned int *' but the argument type is 'void *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 22) requires 'unsigned int *' but the argument type is 'const char *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 23) requires 'unsigned int *' but the argument type is 'const wchar_t *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 24) requires 'unsigned int *' but the argument type is 'const unsigned int *'.\n"); + std::string result_win64("[test.cpp:23]: (warning) %u in format string (no. 1) requires 'unsigned int *' but the argument type is 'bool *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 2) requires 'unsigned int *' but the argument type is 'char *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 3) requires 'unsigned int *' but the argument type is 'signed char *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 4) requires 'unsigned int *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 5) requires 'unsigned int *' but the argument type is 'short *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 6) requires 'unsigned int *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 7) requires 'unsigned int *' but the argument type is 'int *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 9) requires 'unsigned int *' but the argument type is 'long *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 10) requires 'unsigned int *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 11) requires 'unsigned int *' but the argument type is 'long long *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 12) requires 'unsigned int *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 13) requires 'unsigned int *' but the argument type is 'float *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 14) requires 'unsigned int *' but the argument type is 'double *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 15) requires 'unsigned int *' but the argument type is 'long double *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 16) requires 'unsigned int *' but the argument type is 'size_t * {aka unsigned long long *}'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 17) requires 'unsigned int *' but the argument type is 'ptrdiff_t * {aka long long *}'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 18) requires 'unsigned int *' but the argument type is 'intmax_t * {aka long long *}'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 19) requires 'unsigned int *' but the argument type is 'uintmax_t * {aka unsigned long long *}'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 20) requires 'unsigned int *' but the argument type is 'void * *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 21) requires 'unsigned int *' but the argument type is 'void *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 22) requires 'unsigned int *' but the argument type is 'const char *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 23) requires 'unsigned int *' but the argument type is 'const wchar_t *'.\n" + "[test.cpp:23]: (warning) %u in format string (no. 24) requires 'unsigned int *' but the argument type is 'const unsigned int *'.\n"); - check("void foo() {\n" - " bool b;\n" - " char c;\n" - " signed char sc;\n" - " unsigned char uc;\n" - " short s;\n" - " unsigned short us;\n" - " int i;\n" - " unsigned int ui;\n" - " long l;\n" - " unsigned long ul;\n" - " long long ll;\n" - " unsigned long long ull;\n" - " float f;\n" - " double d;\n" - " long double ld;\n" - " size_t st;\n" - " ptrdiff_t pt;\n" - " intmax_t it;\n" - " uintmax_t ut;\n" - " void * vp;\n" - " scanf(\"%lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\",\n" - " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, &unknown, unknown);\n" - "}\n", true); - ASSERT_EQUALS("[test.cpp:22]: (warning) %lu in format string (no. 1) requires 'unsigned long *' but the argument type is 'bool *'.\n" - "[test.cpp:22]: (warning) %lu in format string (no. 2) requires 'unsigned long *' but the argument type is 'char *'.\n" - "[test.cpp:22]: (warning) %lu in format string (no. 3) requires 'unsigned long *' but the argument type is 'signed char *'.\n" - "[test.cpp:22]: (warning) %lu in format string (no. 4) requires 'unsigned long *' but the argument type is 'unsigned char *'.\n" - "[test.cpp:22]: (warning) %lu in format string (no. 5) requires 'unsigned long *' but the argument type is 'short *'.\n" - "[test.cpp:22]: (warning) %lu in format string (no. 6) requires 'unsigned long *' but the argument type is 'unsigned short *'.\n" - "[test.cpp:22]: (warning) %lu in format string (no. 7) requires 'unsigned long *' but the argument type is 'int *'.\n" - "[test.cpp:22]: (warning) %lu in format string (no. 8) requires 'unsigned long *' but the argument type is 'unsigned int *'.\n" - "[test.cpp:22]: (warning) %lu in format string (no. 9) requires 'unsigned long *' but the argument type is 'long *'.\n" - "[test.cpp:22]: (warning) %lu in format string (no. 11) requires 'unsigned long *' but the argument type is 'long long *'.\n" - "[test.cpp:22]: (warning) %lu in format string (no. 12) requires 'unsigned long *' but the argument type is 'unsigned long long *'.\n" - "[test.cpp:22]: (warning) %lu in format string (no. 13) requires 'unsigned long *' but the argument type is 'float *'.\n" - "[test.cpp:22]: (warning) %lu in format string (no. 14) requires 'unsigned long *' but the argument type is 'double *'.\n" - "[test.cpp:22]: (warning) %lu in format string (no. 15) requires 'unsigned long *' but the argument type is 'long double *'.\n" - "[test.cpp:22]: (warning) %lu in format string (no. 16) requires 'unsigned long *' but the argument type is 'size_t * {aka unsigned long *}'.\n" - "[test.cpp:22]: (warning) %lu in format string (no. 17) requires 'unsigned long *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" - "[test.cpp:22]: (warning) %lu in format string (no. 18) requires 'unsigned long *' but the argument type is 'intmax_t * {aka long *}'.\n" - "[test.cpp:22]: (warning) %lu in format string (no. 19) requires 'unsigned long *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" - "[test.cpp:22]: (warning) %lu in format string (no. 20) requires 'unsigned long *' but the argument type is 'void * *'.\n" - "[test.cpp:22]: (warning) %lu in format string (no. 21) requires 'unsigned long *' but the argument type is 'void *'.\n", errout.str()); + check(code, true, false, Settings::Unix32); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Unix64); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win32A); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win64); + ASSERT_EQUALS(result_win64, errout.str()); + } - check("void foo() {\n" - " bool b;\n" - " char c;\n" - " signed char sc;\n" - " unsigned char uc;\n" - " short s;\n" - " unsigned short us;\n" - " int i;\n" - " unsigned int ui;\n" - " long l;\n" - " unsigned long ul;\n" - " long long ll;\n" - " unsigned long long ull;\n" - " float f;\n" - " double d;\n" - " long double ld;\n" - " size_t st;\n" - " ptrdiff_t pt;\n" - " intmax_t it;\n" - " uintmax_t ut;\n" - " void * vp;\n" - " scanf(\"%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu\",\n" - " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, &unknown, unknown);\n" - "}\n", true); - ASSERT_EQUALS("[test.cpp:22]: (warning) %llu in format string (no. 1) requires 'unsigned long long *' but the argument type is 'bool *'.\n" - "[test.cpp:22]: (warning) %llu in format string (no. 2) requires 'unsigned long long *' but the argument type is 'char *'.\n" - "[test.cpp:22]: (warning) %llu in format string (no. 3) requires 'unsigned long long *' but the argument type is 'signed char *'.\n" - "[test.cpp:22]: (warning) %llu in format string (no. 4) requires 'unsigned long long *' but the argument type is 'unsigned char *'.\n" - "[test.cpp:22]: (warning) %llu in format string (no. 5) requires 'unsigned long long *' but the argument type is 'short *'.\n" - "[test.cpp:22]: (warning) %llu in format string (no. 6) requires 'unsigned long long *' but the argument type is 'unsigned short *'.\n" - "[test.cpp:22]: (warning) %llu in format string (no. 7) requires 'unsigned long long *' but the argument type is 'int *'.\n" - "[test.cpp:22]: (warning) %llu in format string (no. 8) requires 'unsigned long long *' but the argument type is 'unsigned int *'.\n" - "[test.cpp:22]: (warning) %llu in format string (no. 9) requires 'unsigned long long *' but the argument type is 'long *'.\n" - "[test.cpp:22]: (warning) %llu in format string (no. 10) requires 'unsigned long long *' but the argument type is 'unsigned long *'.\n" - "[test.cpp:22]: (warning) %llu in format string (no. 11) requires 'unsigned long long *' but the argument type is 'long long *'.\n" - "[test.cpp:22]: (warning) %llu in format string (no. 13) requires 'unsigned long long *' but the argument type is 'float *'.\n" - "[test.cpp:22]: (warning) %llu in format string (no. 14) requires 'unsigned long long *' but the argument type is 'double *'.\n" - "[test.cpp:22]: (warning) %llu in format string (no. 15) requires 'unsigned long long *' but the argument type is 'long double *'.\n" - "[test.cpp:22]: (warning) %llu in format string (no. 16) requires 'unsigned long long *' but the argument type is 'size_t * {aka unsigned long *}'.\n" - "[test.cpp:22]: (warning) %llu in format string (no. 17) requires 'unsigned long long *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" - "[test.cpp:22]: (warning) %llu in format string (no. 18) requires 'unsigned long long *' but the argument type is 'intmax_t * {aka long *}'.\n" - "[test.cpp:22]: (warning) %llu in format string (no. 19) requires 'unsigned long long *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" - "[test.cpp:22]: (warning) %llu in format string (no. 20) requires 'unsigned long long *' but the argument type is 'void * *'.\n" - "[test.cpp:22]: (warning) %llu in format string (no. 21) requires 'unsigned long long *' but the argument type is 'void *'.\n", errout.str()); + { + const char * code = "void foo() {\n" + " bool b;\n" + " char c;\n" + " signed char sc;\n" + " unsigned char uc;\n" + " short s;\n" + " unsigned short us;\n" + " int i;\n" + " unsigned int ui;\n" + " long l;\n" + " unsigned long ul;\n" + " long long ll;\n" + " unsigned long long ull;\n" + " float f;\n" + " double d;\n" + " long double ld;\n" + " size_t st;\n" + " ptrdiff_t pt;\n" + " intmax_t it;\n" + " uintmax_t ut;\n" + " void * vp;\n" + " scanf(\"%lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\",\n" + " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, &unknown, unknown);\n" + "}\n"; + std::string result("[test.cpp:22]: (warning) %lu in format string (no. 1) requires 'unsigned long *' but the argument type is 'bool *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 2) requires 'unsigned long *' but the argument type is 'char *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 3) requires 'unsigned long *' but the argument type is 'signed char *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 4) requires 'unsigned long *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 5) requires 'unsigned long *' but the argument type is 'short *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 6) requires 'unsigned long *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 7) requires 'unsigned long *' but the argument type is 'int *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 8) requires 'unsigned long *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 9) requires 'unsigned long *' but the argument type is 'long *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 11) requires 'unsigned long *' but the argument type is 'long long *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 12) requires 'unsigned long *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 13) requires 'unsigned long *' but the argument type is 'float *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 14) requires 'unsigned long *' but the argument type is 'double *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 15) requires 'unsigned long *' but the argument type is 'long double *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 16) requires 'unsigned long *' but the argument type is 'size_t * {aka unsigned long *}'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 17) requires 'unsigned long *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 18) requires 'unsigned long *' but the argument type is 'intmax_t * {aka long *}'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 19) requires 'unsigned long *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 20) requires 'unsigned long *' but the argument type is 'void * *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 21) requires 'unsigned long *' but the argument type is 'void *'.\n"); + std::string result_win64("[test.cpp:22]: (warning) %lu in format string (no. 1) requires 'unsigned long *' but the argument type is 'bool *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 2) requires 'unsigned long *' but the argument type is 'char *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 3) requires 'unsigned long *' but the argument type is 'signed char *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 4) requires 'unsigned long *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 5) requires 'unsigned long *' but the argument type is 'short *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 6) requires 'unsigned long *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 7) requires 'unsigned long *' but the argument type is 'int *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 8) requires 'unsigned long *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 9) requires 'unsigned long *' but the argument type is 'long *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 11) requires 'unsigned long *' but the argument type is 'long long *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 12) requires 'unsigned long *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 13) requires 'unsigned long *' but the argument type is 'float *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 14) requires 'unsigned long *' but the argument type is 'double *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 15) requires 'unsigned long *' but the argument type is 'long double *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 16) requires 'unsigned long *' but the argument type is 'size_t * {aka unsigned long long *}'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 17) requires 'unsigned long *' but the argument type is 'ptrdiff_t * {aka long long *}'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 18) requires 'unsigned long *' but the argument type is 'intmax_t * {aka long long *}'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 19) requires 'unsigned long *' but the argument type is 'uintmax_t * {aka unsigned long long *}'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 20) requires 'unsigned long *' but the argument type is 'void * *'.\n" + "[test.cpp:22]: (warning) %lu in format string (no. 21) requires 'unsigned long *' but the argument type is 'void *'.\n"); - check("void foo() {\n" - " bool b;\n" - " char c;\n" - " signed char sc;\n" - " unsigned char uc;\n" - " short s;\n" - " unsigned short us;\n" - " int i;\n" - " unsigned int ui;\n" - " long l;\n" - " unsigned long ul;\n" - " long long ll;\n" - " unsigned long long ull;\n" - " float f;\n" - " double d;\n" - " long double ld;\n" - " size_t st;\n" - " ptrdiff_t pt;\n" - " intmax_t it;\n" - " uintmax_t ut;\n" - " void * vp;\n" - " scanf(\"%hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu\",\n" - " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, &unknown, unknown);\n" - "}\n", true); - ASSERT_EQUALS("[test.cpp:22]: (warning) %hu in format string (no. 1) requires 'unsigned short *' but the argument type is 'bool *'.\n" - "[test.cpp:22]: (warning) %hu in format string (no. 2) requires 'unsigned short *' but the argument type is 'char *'.\n" - "[test.cpp:22]: (warning) %hu in format string (no. 3) requires 'unsigned short *' but the argument type is 'signed char *'.\n" - "[test.cpp:22]: (warning) %hu in format string (no. 4) requires 'unsigned short *' but the argument type is 'unsigned char *'.\n" - "[test.cpp:22]: (warning) %hu in format string (no. 5) requires 'unsigned short *' but the argument type is 'short *'.\n" - "[test.cpp:22]: (warning) %hu in format string (no. 7) requires 'unsigned short *' but the argument type is 'int *'.\n" - "[test.cpp:22]: (warning) %hu in format string (no. 8) requires 'unsigned short *' but the argument type is 'unsigned int *'.\n" - "[test.cpp:22]: (warning) %hu in format string (no. 9) requires 'unsigned short *' but the argument type is 'long *'.\n" - "[test.cpp:22]: (warning) %hu in format string (no. 10) requires 'unsigned short *' but the argument type is 'unsigned long *'.\n" - "[test.cpp:22]: (warning) %hu in format string (no. 11) requires 'unsigned short *' but the argument type is 'long long *'.\n" - "[test.cpp:22]: (warning) %hu in format string (no. 12) requires 'unsigned short *' but the argument type is 'unsigned long long *'.\n" - "[test.cpp:22]: (warning) %hu in format string (no. 13) requires 'unsigned short *' but the argument type is 'float *'.\n" - "[test.cpp:22]: (warning) %hu in format string (no. 14) requires 'unsigned short *' but the argument type is 'double *'.\n" - "[test.cpp:22]: (warning) %hu in format string (no. 15) requires 'unsigned short *' but the argument type is 'long double *'.\n" - "[test.cpp:22]: (warning) %hu in format string (no. 16) requires 'unsigned short *' but the argument type is 'size_t * {aka unsigned long *}'.\n" - "[test.cpp:22]: (warning) %hu in format string (no. 17) requires 'unsigned short *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" - "[test.cpp:22]: (warning) %hu in format string (no. 18) requires 'unsigned short *' but the argument type is 'intmax_t * {aka long *}'.\n" - "[test.cpp:22]: (warning) %hu in format string (no. 19) requires 'unsigned short *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" - "[test.cpp:22]: (warning) %hu in format string (no. 20) requires 'unsigned short *' but the argument type is 'void * *'.\n" - "[test.cpp:22]: (warning) %hu in format string (no. 21) requires 'unsigned short *' but the argument type is 'void *'.\n", errout.str()); + check(code, true, false, Settings::Unix32); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Unix64); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win32A); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win64); + ASSERT_EQUALS(result_win64, errout.str()); + } - check("void foo() {\n" - " bool b;\n" - " char c;\n" - " signed char sc;\n" - " unsigned char uc;\n" - " short s;\n" - " unsigned short us;\n" - " int i;\n" - " unsigned int ui;\n" - " long l;\n" - " unsigned long ul;\n" - " long long ll;\n" - " unsigned long long ull;\n" - " float f;\n" - " double d;\n" - " long double ld;\n" - " size_t st;\n" - " ptrdiff_t pt;\n" - " intmax_t it;\n" - " uintmax_t ut;\n" - " void * vp;\n" - " scanf(\"%hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu\",\n" - " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, &unknown, unknown);\n" - "}\n", true); - ASSERT_EQUALS("[test.cpp:22]: (warning) %hhu in format string (no. 1) requires 'unsigned char *' but the argument type is 'bool *'.\n" - "[test.cpp:22]: (warning) %hhu in format string (no. 2) requires 'unsigned char *' but the argument type is 'char *'.\n" - "[test.cpp:22]: (warning) %hhu in format string (no. 3) requires 'unsigned char *' but the argument type is 'signed char *'.\n" - "[test.cpp:22]: (warning) %hhu in format string (no. 5) requires 'unsigned char *' but the argument type is 'short *'.\n" - "[test.cpp:22]: (warning) %hhu in format string (no. 6) requires 'unsigned char *' but the argument type is 'unsigned short *'.\n" - "[test.cpp:22]: (warning) %hhu in format string (no. 7) requires 'unsigned char *' but the argument type is 'int *'.\n" - "[test.cpp:22]: (warning) %hhu in format string (no. 8) requires 'unsigned char *' but the argument type is 'unsigned int *'.\n" - "[test.cpp:22]: (warning) %hhu in format string (no. 9) requires 'unsigned char *' but the argument type is 'long *'.\n" - "[test.cpp:22]: (warning) %hhu in format string (no. 10) requires 'unsigned char *' but the argument type is 'unsigned long *'.\n" - "[test.cpp:22]: (warning) %hhu in format string (no. 11) requires 'unsigned char *' but the argument type is 'long long *'.\n" - "[test.cpp:22]: (warning) %hhu in format string (no. 12) requires 'unsigned char *' but the argument type is 'unsigned long long *'.\n" - "[test.cpp:22]: (warning) %hhu in format string (no. 13) requires 'unsigned char *' but the argument type is 'float *'.\n" - "[test.cpp:22]: (warning) %hhu in format string (no. 14) requires 'unsigned char *' but the argument type is 'double *'.\n" - "[test.cpp:22]: (warning) %hhu in format string (no. 15) requires 'unsigned char *' but the argument type is 'long double *'.\n" - "[test.cpp:22]: (warning) %hhu in format string (no. 16) requires 'unsigned char *' but the argument type is 'size_t * {aka unsigned long *}'.\n" - "[test.cpp:22]: (warning) %hhu in format string (no. 17) requires 'unsigned char *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" - "[test.cpp:22]: (warning) %hhu in format string (no. 18) requires 'unsigned char *' but the argument type is 'intmax_t * {aka long *}'.\n" - "[test.cpp:22]: (warning) %hhu in format string (no. 19) requires 'unsigned char *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" - "[test.cpp:22]: (warning) %hhu in format string (no. 20) requires 'unsigned char *' but the argument type is 'void * *'.\n" - "[test.cpp:22]: (warning) %hhu in format string (no. 21) requires 'unsigned char *' but the argument type is 'void *'.\n", errout.str()); + { + const char * code = "void foo() {\n" + " bool b;\n" + " char c;\n" + " signed char sc;\n" + " unsigned char uc;\n" + " short s;\n" + " unsigned short us;\n" + " int i;\n" + " unsigned int ui;\n" + " long l;\n" + " unsigned long ul;\n" + " long long ll;\n" + " unsigned long long ull;\n" + " float f;\n" + " double d;\n" + " long double ld;\n" + " size_t st;\n" + " ptrdiff_t pt;\n" + " intmax_t it;\n" + " uintmax_t ut;\n" + " void * vp;\n" + " scanf(\"%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu\",\n" + " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, &unknown, unknown);\n" + "}\n"; + std::string result("[test.cpp:22]: (warning) %llu in format string (no. 1) requires 'unsigned long long *' but the argument type is 'bool *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 2) requires 'unsigned long long *' but the argument type is 'char *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 3) requires 'unsigned long long *' but the argument type is 'signed char *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 4) requires 'unsigned long long *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 5) requires 'unsigned long long *' but the argument type is 'short *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 6) requires 'unsigned long long *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 7) requires 'unsigned long long *' but the argument type is 'int *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 8) requires 'unsigned long long *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 9) requires 'unsigned long long *' but the argument type is 'long *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 10) requires 'unsigned long long *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 11) requires 'unsigned long long *' but the argument type is 'long long *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 13) requires 'unsigned long long *' but the argument type is 'float *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 14) requires 'unsigned long long *' but the argument type is 'double *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 15) requires 'unsigned long long *' but the argument type is 'long double *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 16) requires 'unsigned long long *' but the argument type is 'size_t * {aka unsigned long *}'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 17) requires 'unsigned long long *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 18) requires 'unsigned long long *' but the argument type is 'intmax_t * {aka long *}'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 19) requires 'unsigned long long *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 20) requires 'unsigned long long *' but the argument type is 'void * *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 21) requires 'unsigned long long *' but the argument type is 'void *'.\n"); + std::string result_win64("[test.cpp:22]: (warning) %llu in format string (no. 1) requires 'unsigned long long *' but the argument type is 'bool *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 2) requires 'unsigned long long *' but the argument type is 'char *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 3) requires 'unsigned long long *' but the argument type is 'signed char *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 4) requires 'unsigned long long *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 5) requires 'unsigned long long *' but the argument type is 'short *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 6) requires 'unsigned long long *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 7) requires 'unsigned long long *' but the argument type is 'int *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 8) requires 'unsigned long long *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 9) requires 'unsigned long long *' but the argument type is 'long *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 10) requires 'unsigned long long *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 11) requires 'unsigned long long *' but the argument type is 'long long *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 13) requires 'unsigned long long *' but the argument type is 'float *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 14) requires 'unsigned long long *' but the argument type is 'double *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 15) requires 'unsigned long long *' but the argument type is 'long double *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 16) requires 'unsigned long long *' but the argument type is 'size_t * {aka unsigned long long *}'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 17) requires 'unsigned long long *' but the argument type is 'ptrdiff_t * {aka long long *}'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 18) requires 'unsigned long long *' but the argument type is 'intmax_t * {aka long long *}'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 19) requires 'unsigned long long *' but the argument type is 'uintmax_t * {aka unsigned long long *}'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 20) requires 'unsigned long long *' but the argument type is 'void * *'.\n" + "[test.cpp:22]: (warning) %llu in format string (no. 21) requires 'unsigned long long *' but the argument type is 'void *'.\n"); - check("void foo() {\n" - " bool b;\n" - " char c;\n" - " signed char sc;\n" - " unsigned char uc;\n" - " short s;\n" - " unsigned short us;\n" - " int i;\n" - " unsigned int ui;\n" - " long l;\n" - " unsigned long ul;\n" - " long long ll;\n" - " unsigned long long ull;\n" - " float f;\n" - " double d;\n" - " long double ld;\n" - " size_t st;\n" - " ptrdiff_t pt;\n" - " intmax_t it;\n" - " uintmax_t ut;\n" - " void * vp;\n" - " scanf(\"%Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu\",\n" - " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, &unknown, unknown);\n" - "}\n", true); - ASSERT_EQUALS("[test.cpp:22]: (warning) %Lu in format string (no. 1) requires 'unsigned long long *' but the argument type is 'bool *'.\n" - "[test.cpp:22]: (warning) %Lu in format string (no. 2) requires 'unsigned long long *' but the argument type is 'char *'.\n" - "[test.cpp:22]: (warning) %Lu in format string (no. 3) requires 'unsigned long long *' but the argument type is 'signed char *'.\n" - "[test.cpp:22]: (warning) %Lu in format string (no. 4) requires 'unsigned long long *' but the argument type is 'unsigned char *'.\n" - "[test.cpp:22]: (warning) %Lu in format string (no. 5) requires 'unsigned long long *' but the argument type is 'short *'.\n" - "[test.cpp:22]: (warning) %Lu in format string (no. 6) requires 'unsigned long long *' but the argument type is 'unsigned short *'.\n" - "[test.cpp:22]: (warning) %Lu in format string (no. 7) requires 'unsigned long long *' but the argument type is 'int *'.\n" - "[test.cpp:22]: (warning) %Lu in format string (no. 8) requires 'unsigned long long *' but the argument type is 'unsigned int *'.\n" - "[test.cpp:22]: (warning) %Lu in format string (no. 9) requires 'unsigned long long *' but the argument type is 'long *'.\n" - "[test.cpp:22]: (warning) %Lu in format string (no. 10) requires 'unsigned long long *' but the argument type is 'unsigned long *'.\n" - "[test.cpp:22]: (warning) %Lu in format string (no. 11) requires 'unsigned long long *' but the argument type is 'long long *'.\n" - "[test.cpp:22]: (warning) %Lu in format string (no. 13) requires 'unsigned long long *' but the argument type is 'float *'.\n" - "[test.cpp:22]: (warning) %Lu in format string (no. 14) requires 'unsigned long long *' but the argument type is 'double *'.\n" - "[test.cpp:22]: (warning) %Lu in format string (no. 15) requires 'unsigned long long *' but the argument type is 'long double *'.\n" - "[test.cpp:22]: (warning) %Lu in format string (no. 16) requires 'unsigned long long *' but the argument type is 'size_t * {aka unsigned long *}'.\n" - "[test.cpp:22]: (warning) %Lu in format string (no. 17) requires 'unsigned long long *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" - "[test.cpp:22]: (warning) %Lu in format string (no. 18) requires 'unsigned long long *' but the argument type is 'intmax_t * {aka long *}'.\n" - "[test.cpp:22]: (warning) %Lu in format string (no. 19) requires 'unsigned long long *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" - "[test.cpp:22]: (warning) %Lu in format string (no. 20) requires 'unsigned long long *' but the argument type is 'void * *'.\n" - "[test.cpp:22]: (warning) %Lu in format string (no. 21) requires 'unsigned long long *' but the argument type is 'void *'.\n", errout.str()); + check(code, true, false, Settings::Unix32); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Unix64); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win32A); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win64); + ASSERT_EQUALS(result_win64, errout.str()); + } - check("void foo() {\n" - " bool b;\n" - " char c;\n" - " signed char sc;\n" - " unsigned char uc;\n" - " short s;\n" - " unsigned short us;\n" - " int i;\n" - " unsigned int ui;\n" - " long l;\n" - " unsigned long ul;\n" - " long long ll;\n" - " unsigned long long ull;\n" - " float f;\n" - " double d;\n" - " long double ld;\n" - " size_t st;\n" - " ptrdiff_t pt;\n" - " intmax_t it;\n" - " uintmax_t ut;\n" - " void * vp;\n" - " scanf(\"%ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju\",\n" - " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, &unknown, unknown);\n" - "}\n", true); - ASSERT_EQUALS("[test.cpp:22]: (warning) %ju in format string (no. 1) requires 'uintmax_t *' but the argument type is 'bool *'.\n" - "[test.cpp:22]: (warning) %ju in format string (no. 2) requires 'uintmax_t *' but the argument type is 'char *'.\n" - "[test.cpp:22]: (warning) %ju in format string (no. 3) requires 'uintmax_t *' but the argument type is 'signed char *'.\n" - "[test.cpp:22]: (warning) %ju in format string (no. 4) requires 'uintmax_t *' but the argument type is 'unsigned char *'.\n" - "[test.cpp:22]: (warning) %ju in format string (no. 5) requires 'uintmax_t *' but the argument type is 'short *'.\n" - "[test.cpp:22]: (warning) %ju in format string (no. 6) requires 'uintmax_t *' but the argument type is 'unsigned short *'.\n" - "[test.cpp:22]: (warning) %ju in format string (no. 7) requires 'uintmax_t *' but the argument type is 'int *'.\n" - "[test.cpp:22]: (warning) %ju in format string (no. 8) requires 'uintmax_t *' but the argument type is 'unsigned int *'.\n" - "[test.cpp:22]: (warning) %ju in format string (no. 9) requires 'uintmax_t *' but the argument type is 'long *'.\n" - "[test.cpp:22]: (warning) %ju in format string (no. 10) requires 'uintmax_t *' but the argument type is 'unsigned long *'.\n" - "[test.cpp:22]: (warning) %ju in format string (no. 11) requires 'uintmax_t *' but the argument type is 'long long *'.\n" - "[test.cpp:22]: (warning) %ju in format string (no. 12) requires 'uintmax_t *' but the argument type is 'unsigned long long *'.\n" - "[test.cpp:22]: (warning) %ju in format string (no. 13) requires 'uintmax_t *' but the argument type is 'float *'.\n" - "[test.cpp:22]: (warning) %ju in format string (no. 14) requires 'uintmax_t *' but the argument type is 'double *'.\n" - "[test.cpp:22]: (warning) %ju in format string (no. 15) requires 'uintmax_t *' but the argument type is 'long double *'.\n" - "[test.cpp:22]: (warning) %ju in format string (no. 16) requires 'uintmax_t *' but the argument type is 'size_t * {aka unsigned long *}'.\n" - "[test.cpp:22]: (warning) %ju in format string (no. 17) requires 'uintmax_t *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" - "[test.cpp:22]: (warning) %ju in format string (no. 18) requires 'uintmax_t *' but the argument type is 'intmax_t * {aka long *}'.\n" - "[test.cpp:22]: (warning) %ju in format string (no. 20) requires 'uintmax_t *' but the argument type is 'void * *'.\n" - "[test.cpp:22]: (warning) %ju in format string (no. 21) requires 'uintmax_t *' but the argument type is 'void *'.\n", errout.str()); + { + const char * code = "void foo() {\n" + " bool b;\n" + " char c;\n" + " signed char sc;\n" + " unsigned char uc;\n" + " short s;\n" + " unsigned short us;\n" + " int i;\n" + " unsigned int ui;\n" + " long l;\n" + " unsigned long ul;\n" + " long long ll;\n" + " unsigned long long ull;\n" + " float f;\n" + " double d;\n" + " long double ld;\n" + " size_t st;\n" + " ptrdiff_t pt;\n" + " intmax_t it;\n" + " uintmax_t ut;\n" + " void * vp;\n" + " scanf(\"%hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu\",\n" + " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, &unknown, unknown);\n" + "}\n"; + std::string result("[test.cpp:22]: (warning) %hu in format string (no. 1) requires 'unsigned short *' but the argument type is 'bool *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 2) requires 'unsigned short *' but the argument type is 'char *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 3) requires 'unsigned short *' but the argument type is 'signed char *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 4) requires 'unsigned short *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 5) requires 'unsigned short *' but the argument type is 'short *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 7) requires 'unsigned short *' but the argument type is 'int *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 8) requires 'unsigned short *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 9) requires 'unsigned short *' but the argument type is 'long *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 10) requires 'unsigned short *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 11) requires 'unsigned short *' but the argument type is 'long long *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 12) requires 'unsigned short *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 13) requires 'unsigned short *' but the argument type is 'float *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 14) requires 'unsigned short *' but the argument type is 'double *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 15) requires 'unsigned short *' but the argument type is 'long double *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 16) requires 'unsigned short *' but the argument type is 'size_t * {aka unsigned long *}'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 17) requires 'unsigned short *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 18) requires 'unsigned short *' but the argument type is 'intmax_t * {aka long *}'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 19) requires 'unsigned short *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 20) requires 'unsigned short *' but the argument type is 'void * *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 21) requires 'unsigned short *' but the argument type is 'void *'.\n"); + std::string result_win64("[test.cpp:22]: (warning) %hu in format string (no. 1) requires 'unsigned short *' but the argument type is 'bool *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 2) requires 'unsigned short *' but the argument type is 'char *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 3) requires 'unsigned short *' but the argument type is 'signed char *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 4) requires 'unsigned short *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 5) requires 'unsigned short *' but the argument type is 'short *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 7) requires 'unsigned short *' but the argument type is 'int *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 8) requires 'unsigned short *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 9) requires 'unsigned short *' but the argument type is 'long *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 10) requires 'unsigned short *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 11) requires 'unsigned short *' but the argument type is 'long long *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 12) requires 'unsigned short *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 13) requires 'unsigned short *' but the argument type is 'float *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 14) requires 'unsigned short *' but the argument type is 'double *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 15) requires 'unsigned short *' but the argument type is 'long double *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 16) requires 'unsigned short *' but the argument type is 'size_t * {aka unsigned long long *}'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 17) requires 'unsigned short *' but the argument type is 'ptrdiff_t * {aka long long *}'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 18) requires 'unsigned short *' but the argument type is 'intmax_t * {aka long long *}'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 19) requires 'unsigned short *' but the argument type is 'uintmax_t * {aka unsigned long long *}'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 20) requires 'unsigned short *' but the argument type is 'void * *'.\n" + "[test.cpp:22]: (warning) %hu in format string (no. 21) requires 'unsigned short *' but the argument type is 'void *'.\n"); - check("void foo() {\n" - " bool b;\n" - " char c;\n" - " signed char sc;\n" - " unsigned char uc;\n" - " short s;\n" - " unsigned short us;\n" - " int i;\n" - " unsigned int ui;\n" - " long l;\n" - " unsigned long ul;\n" - " long long ll;\n" - " unsigned long long ull;\n" - " float f;\n" - " double d;\n" - " long double ld;\n" - " size_t st;\n" - " ptrdiff_t pt;\n" - " intmax_t it;\n" - " uintmax_t ut;\n" - " void * vp;\n" - " scanf(\"%zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu\",\n" - " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, &unknown, unknown);\n" - "}\n", true); - ASSERT_EQUALS("[test.cpp:22]: (warning) %zu in format string (no. 1) requires 'size_t *' but the argument type is 'bool *'.\n" - "[test.cpp:22]: (warning) %zu in format string (no. 2) requires 'size_t *' but the argument type is 'char *'.\n" - "[test.cpp:22]: (warning) %zu in format string (no. 3) requires 'size_t *' but the argument type is 'signed char *'.\n" - "[test.cpp:22]: (warning) %zu in format string (no. 4) requires 'size_t *' but the argument type is 'unsigned char *'.\n" - "[test.cpp:22]: (warning) %zu in format string (no. 5) requires 'size_t *' but the argument type is 'short *'.\n" - "[test.cpp:22]: (warning) %zu in format string (no. 6) requires 'size_t *' but the argument type is 'unsigned short *'.\n" - "[test.cpp:22]: (warning) %zu in format string (no. 7) requires 'size_t *' but the argument type is 'int *'.\n" - "[test.cpp:22]: (warning) %zu in format string (no. 8) requires 'size_t *' but the argument type is 'unsigned int *'.\n" - "[test.cpp:22]: (warning) %zu in format string (no. 9) requires 'size_t *' but the argument type is 'long *'.\n" - "[test.cpp:22]: (warning) %zu in format string (no. 10) requires 'size_t *' but the argument type is 'unsigned long *'.\n" - "[test.cpp:22]: (warning) %zu in format string (no. 11) requires 'size_t *' but the argument type is 'long long *'.\n" - "[test.cpp:22]: (warning) %zu in format string (no. 12) requires 'size_t *' but the argument type is 'unsigned long long *'.\n" - "[test.cpp:22]: (warning) %zu in format string (no. 13) requires 'size_t *' but the argument type is 'float *'.\n" - "[test.cpp:22]: (warning) %zu in format string (no. 14) requires 'size_t *' but the argument type is 'double *'.\n" - "[test.cpp:22]: (warning) %zu in format string (no. 15) requires 'size_t *' but the argument type is 'long double *'.\n" - "[test.cpp:22]: (warning) %zu in format string (no. 17) requires 'size_t *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" - "[test.cpp:22]: (warning) %zu in format string (no. 18) requires 'size_t *' but the argument type is 'intmax_t * {aka long *}'.\n" - "[test.cpp:22]: (warning) %zu in format string (no. 19) requires 'size_t *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" - "[test.cpp:22]: (warning) %zu in format string (no. 20) requires 'size_t *' but the argument type is 'void * *'.\n" - "[test.cpp:22]: (warning) %zu in format string (no. 21) requires 'size_t *' but the argument type is 'void *'.\n", errout.str()); + check(code, true, false, Settings::Unix32); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Unix64); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win32A); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win64); + ASSERT_EQUALS(result_win64, errout.str()); + } + + { + const char * code = "void foo() {\n" + " bool b;\n" + " char c;\n" + " signed char sc;\n" + " unsigned char uc;\n" + " short s;\n" + " unsigned short us;\n" + " int i;\n" + " unsigned int ui;\n" + " long l;\n" + " unsigned long ul;\n" + " long long ll;\n" + " unsigned long long ull;\n" + " float f;\n" + " double d;\n" + " long double ld;\n" + " size_t st;\n" + " ptrdiff_t pt;\n" + " intmax_t it;\n" + " uintmax_t ut;\n" + " void * vp;\n" + " scanf(\"%hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu\",\n" + " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, &unknown, unknown);\n" + "}\n"; + std::string result("[test.cpp:22]: (warning) %hhu in format string (no. 1) requires 'unsigned char *' but the argument type is 'bool *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 2) requires 'unsigned char *' but the argument type is 'char *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 3) requires 'unsigned char *' but the argument type is 'signed char *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 5) requires 'unsigned char *' but the argument type is 'short *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 6) requires 'unsigned char *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 7) requires 'unsigned char *' but the argument type is 'int *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 8) requires 'unsigned char *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 9) requires 'unsigned char *' but the argument type is 'long *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 10) requires 'unsigned char *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 11) requires 'unsigned char *' but the argument type is 'long long *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 12) requires 'unsigned char *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 13) requires 'unsigned char *' but the argument type is 'float *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 14) requires 'unsigned char *' but the argument type is 'double *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 15) requires 'unsigned char *' but the argument type is 'long double *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 16) requires 'unsigned char *' but the argument type is 'size_t * {aka unsigned long *}'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 17) requires 'unsigned char *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 18) requires 'unsigned char *' but the argument type is 'intmax_t * {aka long *}'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 19) requires 'unsigned char *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 20) requires 'unsigned char *' but the argument type is 'void * *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 21) requires 'unsigned char *' but the argument type is 'void *'.\n"); + std::string result_win64("[test.cpp:22]: (warning) %hhu in format string (no. 1) requires 'unsigned char *' but the argument type is 'bool *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 2) requires 'unsigned char *' but the argument type is 'char *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 3) requires 'unsigned char *' but the argument type is 'signed char *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 5) requires 'unsigned char *' but the argument type is 'short *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 6) requires 'unsigned char *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 7) requires 'unsigned char *' but the argument type is 'int *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 8) requires 'unsigned char *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 9) requires 'unsigned char *' but the argument type is 'long *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 10) requires 'unsigned char *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 11) requires 'unsigned char *' but the argument type is 'long long *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 12) requires 'unsigned char *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 13) requires 'unsigned char *' but the argument type is 'float *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 14) requires 'unsigned char *' but the argument type is 'double *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 15) requires 'unsigned char *' but the argument type is 'long double *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 16) requires 'unsigned char *' but the argument type is 'size_t * {aka unsigned long long *}'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 17) requires 'unsigned char *' but the argument type is 'ptrdiff_t * {aka long long *}'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 18) requires 'unsigned char *' but the argument type is 'intmax_t * {aka long long *}'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 19) requires 'unsigned char *' but the argument type is 'uintmax_t * {aka unsigned long long *}'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 20) requires 'unsigned char *' but the argument type is 'void * *'.\n" + "[test.cpp:22]: (warning) %hhu in format string (no. 21) requires 'unsigned char *' but the argument type is 'void *'.\n"); + + check(code, true, false, Settings::Unix32); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Unix64); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win32A); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win64); + ASSERT_EQUALS(result_win64, errout.str()); + } + + { + const char * code = "void foo() {\n" + " bool b;\n" + " char c;\n" + " signed char sc;\n" + " unsigned char uc;\n" + " short s;\n" + " unsigned short us;\n" + " int i;\n" + " unsigned int ui;\n" + " long l;\n" + " unsigned long ul;\n" + " long long ll;\n" + " unsigned long long ull;\n" + " float f;\n" + " double d;\n" + " long double ld;\n" + " size_t st;\n" + " ptrdiff_t pt;\n" + " intmax_t it;\n" + " uintmax_t ut;\n" + " void * vp;\n" + " scanf(\"%Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu\",\n" + " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, &unknown, unknown);\n" + "}\n"; + std::string result("[test.cpp:22]: (warning) %Lu in format string (no. 1) requires 'unsigned long long *' but the argument type is 'bool *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 2) requires 'unsigned long long *' but the argument type is 'char *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 3) requires 'unsigned long long *' but the argument type is 'signed char *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 4) requires 'unsigned long long *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 5) requires 'unsigned long long *' but the argument type is 'short *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 6) requires 'unsigned long long *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 7) requires 'unsigned long long *' but the argument type is 'int *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 8) requires 'unsigned long long *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 9) requires 'unsigned long long *' but the argument type is 'long *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 10) requires 'unsigned long long *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 11) requires 'unsigned long long *' but the argument type is 'long long *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 13) requires 'unsigned long long *' but the argument type is 'float *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 14) requires 'unsigned long long *' but the argument type is 'double *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 15) requires 'unsigned long long *' but the argument type is 'long double *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 16) requires 'unsigned long long *' but the argument type is 'size_t * {aka unsigned long *}'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 17) requires 'unsigned long long *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 18) requires 'unsigned long long *' but the argument type is 'intmax_t * {aka long *}'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 19) requires 'unsigned long long *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 20) requires 'unsigned long long *' but the argument type is 'void * *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 21) requires 'unsigned long long *' but the argument type is 'void *'.\n"); + std::string result_win64("[test.cpp:22]: (warning) %Lu in format string (no. 1) requires 'unsigned long long *' but the argument type is 'bool *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 2) requires 'unsigned long long *' but the argument type is 'char *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 3) requires 'unsigned long long *' but the argument type is 'signed char *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 4) requires 'unsigned long long *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 5) requires 'unsigned long long *' but the argument type is 'short *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 6) requires 'unsigned long long *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 7) requires 'unsigned long long *' but the argument type is 'int *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 8) requires 'unsigned long long *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 9) requires 'unsigned long long *' but the argument type is 'long *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 10) requires 'unsigned long long *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 11) requires 'unsigned long long *' but the argument type is 'long long *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 13) requires 'unsigned long long *' but the argument type is 'float *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 14) requires 'unsigned long long *' but the argument type is 'double *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 15) requires 'unsigned long long *' but the argument type is 'long double *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 16) requires 'unsigned long long *' but the argument type is 'size_t * {aka unsigned long long *}'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 17) requires 'unsigned long long *' but the argument type is 'ptrdiff_t * {aka long long *}'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 18) requires 'unsigned long long *' but the argument type is 'intmax_t * {aka long long *}'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 19) requires 'unsigned long long *' but the argument type is 'uintmax_t * {aka unsigned long long *}'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 20) requires 'unsigned long long *' but the argument type is 'void * *'.\n" + "[test.cpp:22]: (warning) %Lu in format string (no. 21) requires 'unsigned long long *' but the argument type is 'void *'.\n"); + + check(code, true, false, Settings::Unix32); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Unix64); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win32A); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win64); + // FIXME ASSERT_EQUALS(result_win64, errout.str()); + } + + { + const char * code = "void foo() {\n" + " bool b;\n" + " char c;\n" + " signed char sc;\n" + " unsigned char uc;\n" + " short s;\n" + " unsigned short us;\n" + " int i;\n" + " unsigned int ui;\n" + " long l;\n" + " unsigned long ul;\n" + " long long ll;\n" + " unsigned long long ull;\n" + " float f;\n" + " double d;\n" + " long double ld;\n" + " size_t st;\n" + " ptrdiff_t pt;\n" + " intmax_t it;\n" + " uintmax_t ut;\n" + " void * vp;\n" + " scanf(\"%ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju\",\n" + " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, &unknown, unknown);\n" + "}\n"; + + std::string result("[test.cpp:22]: (warning) %ju in format string (no. 1) requires 'uintmax_t *' but the argument type is 'bool *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 2) requires 'uintmax_t *' but the argument type is 'char *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 3) requires 'uintmax_t *' but the argument type is 'signed char *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 4) requires 'uintmax_t *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 5) requires 'uintmax_t *' but the argument type is 'short *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 6) requires 'uintmax_t *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 7) requires 'uintmax_t *' but the argument type is 'int *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 8) requires 'uintmax_t *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 9) requires 'uintmax_t *' but the argument type is 'long *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 10) requires 'uintmax_t *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 11) requires 'uintmax_t *' but the argument type is 'long long *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 12) requires 'uintmax_t *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 13) requires 'uintmax_t *' but the argument type is 'float *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 14) requires 'uintmax_t *' but the argument type is 'double *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 15) requires 'uintmax_t *' but the argument type is 'long double *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 16) requires 'uintmax_t *' but the argument type is 'size_t * {aka unsigned long *}'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 17) requires 'uintmax_t *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 18) requires 'uintmax_t *' but the argument type is 'intmax_t * {aka long *}'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 20) requires 'uintmax_t *' but the argument type is 'void * *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 21) requires 'uintmax_t *' but the argument type is 'void *'.\n"); + std::string result_win64("[test.cpp:22]: (warning) %ju in format string (no. 1) requires 'uintmax_t *' but the argument type is 'bool *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 2) requires 'uintmax_t *' but the argument type is 'char *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 3) requires 'uintmax_t *' but the argument type is 'signed char *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 4) requires 'uintmax_t *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 5) requires 'uintmax_t *' but the argument type is 'short *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 6) requires 'uintmax_t *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 7) requires 'uintmax_t *' but the argument type is 'int *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 8) requires 'uintmax_t *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 9) requires 'uintmax_t *' but the argument type is 'long *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 10) requires 'uintmax_t *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 11) requires 'uintmax_t *' but the argument type is 'long long *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 12) requires 'uintmax_t *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 13) requires 'uintmax_t *' but the argument type is 'float *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 14) requires 'uintmax_t *' but the argument type is 'double *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 15) requires 'uintmax_t *' but the argument type is 'long double *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 16) requires 'uintmax_t *' but the argument type is 'size_t * {aka unsigned long long *}'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 17) requires 'uintmax_t *' but the argument type is 'ptrdiff_t * {aka long long *}'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 18) requires 'uintmax_t *' but the argument type is 'intmax_t * {aka long long *}'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 20) requires 'uintmax_t *' but the argument type is 'void * *'.\n" + "[test.cpp:22]: (warning) %ju in format string (no. 21) requires 'uintmax_t *' but the argument type is 'void *'.\n"); + + check(code, true, false, Settings::Unix32); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Unix64); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win32A); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win64); + ASSERT_EQUALS(result_win64, errout.str()); + } + + { + const char * code = "void foo() {\n" + " bool b;\n" + " char c;\n" + " signed char sc;\n" + " unsigned char uc;\n" + " short s;\n" + " unsigned short us;\n" + " int i;\n" + " unsigned int ui;\n" + " long l;\n" + " unsigned long ul;\n" + " long long ll;\n" + " unsigned long long ull;\n" + " float f;\n" + " double d;\n" + " long double ld;\n" + " size_t st;\n" + " ptrdiff_t pt;\n" + " intmax_t it;\n" + " uintmax_t ut;\n" + " void * vp;\n" + " scanf(\"%zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu %zu\",\n" + " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, &unknown, unknown);\n" + "}\n"; + std::string result("[test.cpp:22]: (warning) %zu in format string (no. 1) requires 'size_t *' but the argument type is 'bool *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 2) requires 'size_t *' but the argument type is 'char *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 3) requires 'size_t *' but the argument type is 'signed char *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 4) requires 'size_t *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 5) requires 'size_t *' but the argument type is 'short *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 6) requires 'size_t *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 7) requires 'size_t *' but the argument type is 'int *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 8) requires 'size_t *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 9) requires 'size_t *' but the argument type is 'long *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 10) requires 'size_t *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 11) requires 'size_t *' but the argument type is 'long long *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 12) requires 'size_t *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 13) requires 'size_t *' but the argument type is 'float *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 14) requires 'size_t *' but the argument type is 'double *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 15) requires 'size_t *' but the argument type is 'long double *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 17) requires 'size_t *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 18) requires 'size_t *' but the argument type is 'intmax_t * {aka long *}'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 19) requires 'size_t *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 20) requires 'size_t *' but the argument type is 'void * *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 21) requires 'size_t *' but the argument type is 'void *'.\n"); + std::string result_win64("[test.cpp:22]: (warning) %zu in format string (no. 1) requires 'size_t *' but the argument type is 'bool *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 2) requires 'size_t *' but the argument type is 'char *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 3) requires 'size_t *' but the argument type is 'signed char *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 4) requires 'size_t *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 5) requires 'size_t *' but the argument type is 'short *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 6) requires 'size_t *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 7) requires 'size_t *' but the argument type is 'int *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 8) requires 'size_t *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 9) requires 'size_t *' but the argument type is 'long *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 10) requires 'size_t *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 11) requires 'size_t *' but the argument type is 'long long *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 12) requires 'size_t *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 13) requires 'size_t *' but the argument type is 'float *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 14) requires 'size_t *' but the argument type is 'double *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 15) requires 'size_t *' but the argument type is 'long double *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 17) requires 'size_t *' but the argument type is 'ptrdiff_t * {aka long long *}'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 18) requires 'size_t *' but the argument type is 'intmax_t * {aka long long *}'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 19) requires 'size_t *' but the argument type is 'uintmax_t * {aka unsigned long long *}'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 20) requires 'size_t *' but the argument type is 'void * *'.\n" + "[test.cpp:22]: (warning) %zu in format string (no. 21) requires 'size_t *' but the argument type is 'void *'.\n"); + + check(code, true, false, Settings::Unix32); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Unix64); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win32A); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win64); + ASSERT_EQUALS(result_win64, errout.str()); + } check("void foo() {\n" " bool b;\n" @@ -1152,298 +1404,501 @@ private: "[test.cpp:22]: (warning) %I64u in format string (no. 20) requires 'unsigned __int64 *' but the argument type is 'void * *'.\n" "[test.cpp:22]: (warning) %I64u in format string (no. 21) requires 'unsigned __int64 *' but the argument type is 'void *'.\n", errout.str()); - check("const int * foo() { }\n" - "void foo() {\n" - " bool b;\n" - " char c;\n" - " signed char sc;\n" - " unsigned char uc;\n" - " short s;\n" - " unsigned short us;\n" - " int i;\n" - " unsigned int ui;\n" - " long l;\n" - " unsigned long ul;\n" - " long long ll;\n" - " unsigned long long ull;\n" - " float f;\n" - " double d;\n" - " long double ld;\n" - " size_t st;\n" - " ptrdiff_t pt;\n" - " intmax_t it;\n" - " uintmax_t ut;\n" - " void * vp;\n" - " scanf(\"%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\",\n" - " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, \"str\", L\"str\", foo(), &unknown, unknown);\n" - "}\n", true); - ASSERT_EQUALS("[test.cpp:23]: (warning) %d in format string (no. 1) requires 'int *' but the argument type is 'bool *'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 2) requires 'int *' but the argument type is 'char *'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 3) requires 'int *' but the argument type is 'signed char *'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 4) requires 'int *' but the argument type is 'unsigned char *'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 5) requires 'int *' but the argument type is 'short *'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 6) requires 'int *' but the argument type is 'unsigned short *'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 8) requires 'int *' but the argument type is 'unsigned int *'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 9) requires 'int *' but the argument type is 'long *'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 10) requires 'int *' but the argument type is 'unsigned long *'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 11) requires 'int *' but the argument type is 'long long *'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 12) requires 'int *' but the argument type is 'unsigned long long *'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 13) requires 'int *' but the argument type is 'float *'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 14) requires 'int *' but the argument type is 'double *'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 15) requires 'int *' but the argument type is 'long double *'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 16) requires 'int *' but the argument type is 'size_t * {aka unsigned long *}'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 17) requires 'int *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 18) requires 'int *' but the argument type is 'intmax_t * {aka long *}'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 19) requires 'int *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 20) requires 'int *' but the argument type is 'void * *'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 21) requires 'int *' but the argument type is 'void *'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 22) requires 'int *' but the argument type is 'const char *'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 23) requires 'int *' but the argument type is 'const wchar_t *'.\n" - "[test.cpp:23]: (warning) %d in format string (no. 24) requires 'int *' but the argument type is 'const int *'.\n", errout.str()); + { + const char * code = "const int * foo() { }\n" + "void foo() {\n" + " bool b;\n" + " char c;\n" + " signed char sc;\n" + " unsigned char uc;\n" + " short s;\n" + " unsigned short us;\n" + " int i;\n" + " unsigned int ui;\n" + " long l;\n" + " unsigned long ul;\n" + " long long ll;\n" + " unsigned long long ull;\n" + " float f;\n" + " double d;\n" + " long double ld;\n" + " size_t st;\n" + " ptrdiff_t pt;\n" + " intmax_t it;\n" + " uintmax_t ut;\n" + " void * vp;\n" + " scanf(\"%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\",\n" + " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, \"str\", L\"str\", foo(), &unknown, unknown);\n" + "}\n"; + std::string result("[test.cpp:23]: (warning) %d in format string (no. 1) requires 'int *' but the argument type is 'bool *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 2) requires 'int *' but the argument type is 'char *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 3) requires 'int *' but the argument type is 'signed char *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 4) requires 'int *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 5) requires 'int *' but the argument type is 'short *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 6) requires 'int *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 8) requires 'int *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 9) requires 'int *' but the argument type is 'long *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 10) requires 'int *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 11) requires 'int *' but the argument type is 'long long *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 12) requires 'int *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 13) requires 'int *' but the argument type is 'float *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 14) requires 'int *' but the argument type is 'double *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 15) requires 'int *' but the argument type is 'long double *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 16) requires 'int *' but the argument type is 'size_t * {aka unsigned long *}'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 17) requires 'int *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 18) requires 'int *' but the argument type is 'intmax_t * {aka long *}'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 19) requires 'int *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 20) requires 'int *' but the argument type is 'void * *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 21) requires 'int *' but the argument type is 'void *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 22) requires 'int *' but the argument type is 'const char *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 23) requires 'int *' but the argument type is 'const wchar_t *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 24) requires 'int *' but the argument type is 'const int *'.\n"); + std::string result_win64("[test.cpp:23]: (warning) %d in format string (no. 1) requires 'int *' but the argument type is 'bool *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 2) requires 'int *' but the argument type is 'char *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 3) requires 'int *' but the argument type is 'signed char *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 4) requires 'int *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 5) requires 'int *' but the argument type is 'short *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 6) requires 'int *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 8) requires 'int *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 9) requires 'int *' but the argument type is 'long *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 10) requires 'int *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 11) requires 'int *' but the argument type is 'long long *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 12) requires 'int *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 13) requires 'int *' but the argument type is 'float *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 14) requires 'int *' but the argument type is 'double *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 15) requires 'int *' but the argument type is 'long double *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 16) requires 'int *' but the argument type is 'size_t * {aka unsigned long long *}'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 17) requires 'int *' but the argument type is 'ptrdiff_t * {aka long long *}'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 18) requires 'int *' but the argument type is 'intmax_t * {aka long long *}'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 19) requires 'int *' but the argument type is 'uintmax_t * {aka unsigned long long *}'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 20) requires 'int *' but the argument type is 'void * *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 21) requires 'int *' but the argument type is 'void *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 22) requires 'int *' but the argument type is 'const char *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 23) requires 'int *' but the argument type is 'const wchar_t *'.\n" + "[test.cpp:23]: (warning) %d in format string (no. 24) requires 'int *' but the argument type is 'const int *'.\n"); - check("const unsigned int * foo() { }\n" - "void foo() {\n" - " bool b;\n" - " char c;\n" - " signed char sc;\n" - " unsigned char uc;\n" - " short s;\n" - " unsigned short us;\n" - " int i;\n" - " unsigned int ui;\n" - " long l;\n" - " unsigned long ul;\n" - " long long ll;\n" - " unsigned long long ull;\n" - " float f;\n" - " double d;\n" - " long double ld;\n" - " size_t st;\n" - " ptrdiff_t pt;\n" - " intmax_t it;\n" - " uintmax_t ut;\n" - " void * vp;\n" - " scanf(\"%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\",\n" - " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, \"str\", L\"str\", foo(), &unknown, unknown);\n" - "}\n", true); - ASSERT_EQUALS("[test.cpp:23]: (warning) %x in format string (no. 1) requires 'unsigned int *' but the argument type is 'bool *'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 2) requires 'unsigned int *' but the argument type is 'char *'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 3) requires 'unsigned int *' but the argument type is 'signed char *'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 4) requires 'unsigned int *' but the argument type is 'unsigned char *'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 5) requires 'unsigned int *' but the argument type is 'short *'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 6) requires 'unsigned int *' but the argument type is 'unsigned short *'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 9) requires 'unsigned int *' but the argument type is 'long *'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 10) requires 'unsigned int *' but the argument type is 'unsigned long *'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 11) requires 'unsigned int *' but the argument type is 'long long *'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 12) requires 'unsigned int *' but the argument type is 'unsigned long long *'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 13) requires 'unsigned int *' but the argument type is 'float *'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 14) requires 'unsigned int *' but the argument type is 'double *'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 15) requires 'unsigned int *' but the argument type is 'long double *'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 16) requires 'unsigned int *' but the argument type is 'size_t * {aka unsigned long *}'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 17) requires 'unsigned int *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 18) requires 'unsigned int *' but the argument type is 'intmax_t * {aka long *}'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 19) requires 'unsigned int *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 20) requires 'unsigned int *' but the argument type is 'void * *'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 21) requires 'unsigned int *' but the argument type is 'void *'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 22) requires 'unsigned int *' but the argument type is 'const char *'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 23) requires 'unsigned int *' but the argument type is 'const wchar_t *'.\n" - "[test.cpp:23]: (warning) %x in format string (no. 24) requires 'unsigned int *' but the argument type is 'const unsigned int *'.\n", errout.str()); + check(code, true, false, Settings::Unix32); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Unix64); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win32A); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win64); + ASSERT_EQUALS(result_win64, errout.str()); + } - check("const float * foo() { }\n" - "void foo() {\n" - " bool b;\n" - " char c;\n" - " signed char sc;\n" - " unsigned char uc;\n" - " short s;\n" - " unsigned short us;\n" - " int i;\n" - " unsigned int ui;\n" - " long l;\n" - " unsigned long ul;\n" - " long long ll;\n" - " unsigned long long ull;\n" - " float f;\n" - " double d;\n" - " long double ld;\n" - " size_t st;\n" - " ptrdiff_t pt;\n" - " intmax_t it;\n" - " uintmax_t ut;\n" - " void * vp;\n" - " scanf(\"%f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\",\n" - " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, \"str\", L\"str\", foo(), &unknown, unknown);\n" - "}\n", true); - ASSERT_EQUALS("[test.cpp:23]: (warning) %f in format string (no. 1) requires 'float *' but the argument type is 'bool *'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 2) requires 'float *' but the argument type is 'char *'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 3) requires 'float *' but the argument type is 'signed char *'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 4) requires 'float *' but the argument type is 'unsigned char *'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 5) requires 'float *' but the argument type is 'short *'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 6) requires 'float *' but the argument type is 'unsigned short *'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 7) requires 'float *' but the argument type is 'int *'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 8) requires 'float *' but the argument type is 'unsigned int *'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 9) requires 'float *' but the argument type is 'long *'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 10) requires 'float *' but the argument type is 'unsigned long *'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 11) requires 'float *' but the argument type is 'long long *'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 12) requires 'float *' but the argument type is 'unsigned long long *'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 14) requires 'float *' but the argument type is 'double *'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 15) requires 'float *' but the argument type is 'long double *'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 16) requires 'float *' but the argument type is 'size_t * {aka unsigned long *}'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 17) requires 'float *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 18) requires 'float *' but the argument type is 'intmax_t * {aka long *}'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 19) requires 'float *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 20) requires 'float *' but the argument type is 'void * *'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 21) requires 'float *' but the argument type is 'void *'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 22) requires 'float *' but the argument type is 'const char *'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 23) requires 'float *' but the argument type is 'const wchar_t *'.\n" - "[test.cpp:23]: (warning) %f in format string (no. 24) requires 'float *' but the argument type is 'const float *'.\n", errout.str()); + { + const char * code = "const unsigned int * foo() { }\n" + "void foo() {\n" + " bool b;\n" + " char c;\n" + " signed char sc;\n" + " unsigned char uc;\n" + " short s;\n" + " unsigned short us;\n" + " int i;\n" + " unsigned int ui;\n" + " long l;\n" + " unsigned long ul;\n" + " long long ll;\n" + " unsigned long long ull;\n" + " float f;\n" + " double d;\n" + " long double ld;\n" + " size_t st;\n" + " ptrdiff_t pt;\n" + " intmax_t it;\n" + " uintmax_t ut;\n" + " void * vp;\n" + " scanf(\"%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\",\n" + " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, \"str\", L\"str\", foo(), &unknown, unknown);\n" + "}\n"; + std::string result("[test.cpp:23]: (warning) %x in format string (no. 1) requires 'unsigned int *' but the argument type is 'bool *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 2) requires 'unsigned int *' but the argument type is 'char *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 3) requires 'unsigned int *' but the argument type is 'signed char *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 4) requires 'unsigned int *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 5) requires 'unsigned int *' but the argument type is 'short *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 6) requires 'unsigned int *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 9) requires 'unsigned int *' but the argument type is 'long *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 10) requires 'unsigned int *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 11) requires 'unsigned int *' but the argument type is 'long long *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 12) requires 'unsigned int *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 13) requires 'unsigned int *' but the argument type is 'float *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 14) requires 'unsigned int *' but the argument type is 'double *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 15) requires 'unsigned int *' but the argument type is 'long double *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 16) requires 'unsigned int *' but the argument type is 'size_t * {aka unsigned long *}'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 17) requires 'unsigned int *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 18) requires 'unsigned int *' but the argument type is 'intmax_t * {aka long *}'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 19) requires 'unsigned int *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 20) requires 'unsigned int *' but the argument type is 'void * *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 21) requires 'unsigned int *' but the argument type is 'void *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 22) requires 'unsigned int *' but the argument type is 'const char *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 23) requires 'unsigned int *' but the argument type is 'const wchar_t *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 24) requires 'unsigned int *' but the argument type is 'const unsigned int *'.\n"); + std::string result_win64("[test.cpp:23]: (warning) %x in format string (no. 1) requires 'unsigned int *' but the argument type is 'bool *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 2) requires 'unsigned int *' but the argument type is 'char *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 3) requires 'unsigned int *' but the argument type is 'signed char *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 4) requires 'unsigned int *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 5) requires 'unsigned int *' but the argument type is 'short *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 6) requires 'unsigned int *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 9) requires 'unsigned int *' but the argument type is 'long *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 10) requires 'unsigned int *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 11) requires 'unsigned int *' but the argument type is 'long long *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 12) requires 'unsigned int *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 13) requires 'unsigned int *' but the argument type is 'float *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 14) requires 'unsigned int *' but the argument type is 'double *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 15) requires 'unsigned int *' but the argument type is 'long double *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 16) requires 'unsigned int *' but the argument type is 'size_t * {aka unsigned long long *}'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 17) requires 'unsigned int *' but the argument type is 'ptrdiff_t * {aka long long *}'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 18) requires 'unsigned int *' but the argument type is 'intmax_t * {aka long long *}'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 19) requires 'unsigned int *' but the argument type is 'uintmax_t * {aka unsigned long long *}'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 20) requires 'unsigned int *' but the argument type is 'void * *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 21) requires 'unsigned int *' but the argument type is 'void *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 22) requires 'unsigned int *' but the argument type is 'const char *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 23) requires 'unsigned int *' but the argument type is 'const wchar_t *'.\n" + "[test.cpp:23]: (warning) %x in format string (no. 24) requires 'unsigned int *' but the argument type is 'const unsigned int *'.\n"); - check("const double * foo() { }\n" - "void foo() {\n" - " bool b;\n" - " char c;\n" - " signed char sc;\n" - " unsigned char uc;\n" - " short s;\n" - " unsigned short us;\n" - " int i;\n" - " unsigned int ui;\n" - " long l;\n" - " unsigned long ul;\n" - " long long ll;\n" - " unsigned long long ull;\n" - " float f;\n" - " double d;\n" - " long double ld;\n" - " size_t st;\n" - " ptrdiff_t pt;\n" - " intmax_t it;\n" - " uintmax_t ut;\n" - " void * vp;\n" - " scanf(\"%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf\",\n" - " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, \"str\", L\"str\", foo(), &unknown, unknown);\n" - "}\n", true); - ASSERT_EQUALS("[test.cpp:23]: (warning) %lf in format string (no. 1) requires 'double *' but the argument type is 'bool *'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 2) requires 'double *' but the argument type is 'char *'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 3) requires 'double *' but the argument type is 'signed char *'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 4) requires 'double *' but the argument type is 'unsigned char *'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 5) requires 'double *' but the argument type is 'short *'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 6) requires 'double *' but the argument type is 'unsigned short *'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 7) requires 'double *' but the argument type is 'int *'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 8) requires 'double *' but the argument type is 'unsigned int *'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 9) requires 'double *' but the argument type is 'long *'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 10) requires 'double *' but the argument type is 'unsigned long *'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 11) requires 'double *' but the argument type is 'long long *'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 12) requires 'double *' but the argument type is 'unsigned long long *'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 13) requires 'double *' but the argument type is 'float *'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 15) requires 'double *' but the argument type is 'long double *'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 16) requires 'double *' but the argument type is 'size_t * {aka unsigned long *}'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 17) requires 'double *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 18) requires 'double *' but the argument type is 'intmax_t * {aka long *}'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 19) requires 'double *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 20) requires 'double *' but the argument type is 'void * *'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 21) requires 'double *' but the argument type is 'void *'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 22) requires 'double *' but the argument type is 'const char *'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 23) requires 'double *' but the argument type is 'const wchar_t *'.\n" - "[test.cpp:23]: (warning) %lf in format string (no. 24) requires 'double *' but the argument type is 'const double *'.\n", errout.str()); + check(code, true, false, Settings::Unix32); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Unix64); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win32A); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win64); + ASSERT_EQUALS(result_win64, errout.str()); + } - check("const long double * foo() { }\n" - "void foo() {\n" - " bool b;\n" - " char c;\n" - " signed char sc;\n" - " unsigned char uc;\n" - " short s;\n" - " unsigned short us;\n" - " int i;\n" - " unsigned int ui;\n" - " long l;\n" - " unsigned long ul;\n" - " long long ll;\n" - " unsigned long long ull;\n" - " float f;\n" - " double d;\n" - " long double ld;\n" - " size_t st;\n" - " ptrdiff_t pt;\n" - " intmax_t it;\n" - " uintmax_t ut;\n" - " void * vp;\n" - " scanf(\"%Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf\",\n" - " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, \"str\", L\"str\", foo(), &unknown, unknown);\n" - "}\n", true); - ASSERT_EQUALS("[test.cpp:23]: (warning) %Lf in format string (no. 1) requires 'long double *' but the argument type is 'bool *'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 2) requires 'long double *' but the argument type is 'char *'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 3) requires 'long double *' but the argument type is 'signed char *'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 4) requires 'long double *' but the argument type is 'unsigned char *'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 5) requires 'long double *' but the argument type is 'short *'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 6) requires 'long double *' but the argument type is 'unsigned short *'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 7) requires 'long double *' but the argument type is 'int *'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 8) requires 'long double *' but the argument type is 'unsigned int *'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 9) requires 'long double *' but the argument type is 'long *'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 10) requires 'long double *' but the argument type is 'unsigned long *'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 11) requires 'long double *' but the argument type is 'long long *'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 12) requires 'long double *' but the argument type is 'unsigned long long *'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 13) requires 'long double *' but the argument type is 'float *'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 14) requires 'long double *' but the argument type is 'double *'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 16) requires 'long double *' but the argument type is 'size_t * {aka unsigned long *}'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 17) requires 'long double *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 18) requires 'long double *' but the argument type is 'intmax_t * {aka long *}'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 19) requires 'long double *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 20) requires 'long double *' but the argument type is 'void * *'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 21) requires 'long double *' but the argument type is 'void *'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 22) requires 'long double *' but the argument type is 'const char *'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 23) requires 'long double *' but the argument type is 'const wchar_t *'.\n" - "[test.cpp:23]: (warning) %Lf in format string (no. 24) requires 'long double *' but the argument type is 'const long double *'.\n", errout.str()); + { + const char * code = "const float * foo() { }\n" + "void foo() {\n" + " bool b;\n" + " char c;\n" + " signed char sc;\n" + " unsigned char uc;\n" + " short s;\n" + " unsigned short us;\n" + " int i;\n" + " unsigned int ui;\n" + " long l;\n" + " unsigned long ul;\n" + " long long ll;\n" + " unsigned long long ull;\n" + " float f;\n" + " double d;\n" + " long double ld;\n" + " size_t st;\n" + " ptrdiff_t pt;\n" + " intmax_t it;\n" + " uintmax_t ut;\n" + " void * vp;\n" + " scanf(\"%f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\",\n" + " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, \"str\", L\"str\", foo(), &unknown, unknown);\n" + "}\n"; + std::string result("[test.cpp:23]: (warning) %f in format string (no. 1) requires 'float *' but the argument type is 'bool *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 2) requires 'float *' but the argument type is 'char *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 3) requires 'float *' but the argument type is 'signed char *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 4) requires 'float *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 5) requires 'float *' but the argument type is 'short *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 6) requires 'float *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 7) requires 'float *' but the argument type is 'int *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 8) requires 'float *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 9) requires 'float *' but the argument type is 'long *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 10) requires 'float *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 11) requires 'float *' but the argument type is 'long long *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 12) requires 'float *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 14) requires 'float *' but the argument type is 'double *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 15) requires 'float *' but the argument type is 'long double *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 16) requires 'float *' but the argument type is 'size_t * {aka unsigned long *}'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 17) requires 'float *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 18) requires 'float *' but the argument type is 'intmax_t * {aka long *}'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 19) requires 'float *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 20) requires 'float *' but the argument type is 'void * *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 21) requires 'float *' but the argument type is 'void *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 22) requires 'float *' but the argument type is 'const char *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 23) requires 'float *' but the argument type is 'const wchar_t *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 24) requires 'float *' but the argument type is 'const float *'.\n"); + std::string result_win64("[test.cpp:23]: (warning) %f in format string (no. 1) requires 'float *' but the argument type is 'bool *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 2) requires 'float *' but the argument type is 'char *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 3) requires 'float *' but the argument type is 'signed char *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 4) requires 'float *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 5) requires 'float *' but the argument type is 'short *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 6) requires 'float *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 7) requires 'float *' but the argument type is 'int *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 8) requires 'float *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 9) requires 'float *' but the argument type is 'long *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 10) requires 'float *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 11) requires 'float *' but the argument type is 'long long *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 12) requires 'float *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 14) requires 'float *' but the argument type is 'double *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 15) requires 'float *' but the argument type is 'long double *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 16) requires 'float *' but the argument type is 'size_t * {aka unsigned long long *}'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 17) requires 'float *' but the argument type is 'ptrdiff_t * {aka long long *}'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 18) requires 'float *' but the argument type is 'intmax_t * {aka long long *}'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 19) requires 'float *' but the argument type is 'uintmax_t * {aka unsigned long long *}'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 20) requires 'float *' but the argument type is 'void * *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 21) requires 'float *' but the argument type is 'void *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 22) requires 'float *' but the argument type is 'const char *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 23) requires 'float *' but the argument type is 'const wchar_t *'.\n" + "[test.cpp:23]: (warning) %f in format string (no. 24) requires 'float *' but the argument type is 'const float *'.\n"); - check("const int * foo() { }\n" - "void foo() {\n" - " bool b;\n" - " char c;\n" - " signed char sc;\n" - " unsigned char uc;\n" - " short s;\n" - " unsigned short us;\n" - " int i;\n" - " unsigned int ui;\n" - " long l;\n" - " unsigned long ul;\n" - " long long ll;\n" - " unsigned long long ull;\n" - " float f;\n" - " double d;\n" - " long double ld;\n" - " size_t st;\n" - " ptrdiff_t pt;\n" - " intmax_t it;\n" - " uintmax_t ut;\n" - " void * vp;\n" - " scanf(\"%n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n\",\n" - " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, \"str\", L\"str\", foo(), &unknown, unknown);\n" - "}\n", true); - ASSERT_EQUALS("[test.cpp:23]: (warning) %n in format string (no. 1) requires 'int *' but the argument type is 'bool *'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 2) requires 'int *' but the argument type is 'char *'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 3) requires 'int *' but the argument type is 'signed char *'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 4) requires 'int *' but the argument type is 'unsigned char *'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 5) requires 'int *' but the argument type is 'short *'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 6) requires 'int *' but the argument type is 'unsigned short *'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 8) requires 'int *' but the argument type is 'unsigned int *'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 9) requires 'int *' but the argument type is 'long *'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 10) requires 'int *' but the argument type is 'unsigned long *'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 11) requires 'int *' but the argument type is 'long long *'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 12) requires 'int *' but the argument type is 'unsigned long long *'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 13) requires 'int *' but the argument type is 'float *'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 14) requires 'int *' but the argument type is 'double *'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 15) requires 'int *' but the argument type is 'long double *'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 16) requires 'int *' but the argument type is 'size_t * {aka unsigned long *}'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 17) requires 'int *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 18) requires 'int *' but the argument type is 'intmax_t * {aka long *}'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 19) requires 'int *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 20) requires 'int *' but the argument type is 'void * *'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 21) requires 'int *' but the argument type is 'void *'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 22) requires 'int *' but the argument type is 'const char *'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 23) requires 'int *' but the argument type is 'const wchar_t *'.\n" - "[test.cpp:23]: (warning) %n in format string (no. 24) requires 'int *' but the argument type is 'const int *'.\n", errout.str()); + check(code, true, false, Settings::Unix32); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Unix64); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win32A); + ASSERT_EQUALS(result, errout.str()); + check(code, true, false, Settings::Win64); + ASSERT_EQUALS(result_win64, errout.str()); + } + + { + const char * code = "const double * foo() { }\n" + "void foo() {\n" + " bool b;\n" + " char c;\n" + " signed char sc;\n" + " unsigned char uc;\n" + " short s;\n" + " unsigned short us;\n" + " int i;\n" + " unsigned int ui;\n" + " long l;\n" + " unsigned long ul;\n" + " long long ll;\n" + " unsigned long long ull;\n" + " float f;\n" + " double d;\n" + " long double ld;\n" + " size_t st;\n" + " ptrdiff_t pt;\n" + " intmax_t it;\n" + " uintmax_t ut;\n" + " void * vp;\n" + " scanf(\"%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf\",\n" + " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, \"str\", L\"str\", foo(), &unknown, unknown);\n" + "}\n"; + std::string result("[test.cpp:23]: (warning) %lf in format string (no. 1) requires 'double *' but the argument type is 'bool *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 2) requires 'double *' but the argument type is 'char *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 3) requires 'double *' but the argument type is 'signed char *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 4) requires 'double *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 5) requires 'double *' but the argument type is 'short *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 6) requires 'double *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 7) requires 'double *' but the argument type is 'int *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 8) requires 'double *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 9) requires 'double *' but the argument type is 'long *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 10) requires 'double *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 11) requires 'double *' but the argument type is 'long long *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 12) requires 'double *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 13) requires 'double *' but the argument type is 'float *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 15) requires 'double *' but the argument type is 'long double *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 16) requires 'double *' but the argument type is 'size_t * {aka unsigned long *}'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 17) requires 'double *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 18) requires 'double *' but the argument type is 'intmax_t * {aka long *}'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 19) requires 'double *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 20) requires 'double *' but the argument type is 'void * *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 21) requires 'double *' but the argument type is 'void *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 22) requires 'double *' but the argument type is 'const char *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 23) requires 'double *' but the argument type is 'const wchar_t *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 24) requires 'double *' but the argument type is 'const double *'.\n"); + std::string result_win64("[test.cpp:23]: (warning) %lf in format string (no. 1) requires 'double *' but the argument type is 'bool *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 2) requires 'double *' but the argument type is 'char *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 3) requires 'double *' but the argument type is 'signed char *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 4) requires 'double *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 5) requires 'double *' but the argument type is 'short *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 6) requires 'double *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 7) requires 'double *' but the argument type is 'int *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 8) requires 'double *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 9) requires 'double *' but the argument type is 'long *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 10) requires 'double *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 11) requires 'double *' but the argument type is 'long long *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 12) requires 'double *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 13) requires 'double *' but the argument type is 'float *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 15) requires 'double *' but the argument type is 'long double *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 16) requires 'double *' but the argument type is 'size_t * {aka unsigned long long *}'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 17) requires 'double *' but the argument type is 'ptrdiff_t * {aka long long *}'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 18) requires 'double *' but the argument type is 'intmax_t * {aka long long *}'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 19) requires 'double *' but the argument type is 'uintmax_t * {aka unsigned long long *}'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 20) requires 'double *' but the argument type is 'void * *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 21) requires 'double *' but the argument type is 'void *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 22) requires 'double *' but the argument type is 'const char *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 23) requires 'double *' but the argument type is 'const wchar_t *'.\n" + "[test.cpp:23]: (warning) %lf in format string (no. 24) requires 'double *' but the argument type is 'const double *'.\n"); + + check(code, false, false, Settings::Unix32); + ASSERT_EQUALS(result, errout.str()); + check(code, false, false, Settings::Unix64); + ASSERT_EQUALS(result, errout.str()); + check(code, false, false, Settings::Win32A); + ASSERT_EQUALS(result, errout.str()); + check(code, false, false, Settings::Win64); + ASSERT_EQUALS(result_win64, errout.str()); + } + + { + const char * code = "const long double * foo() { }\n" + "void foo() {\n" + " bool b;\n" + " char c;\n" + " signed char sc;\n" + " unsigned char uc;\n" + " short s;\n" + " unsigned short us;\n" + " int i;\n" + " unsigned int ui;\n" + " long l;\n" + " unsigned long ul;\n" + " long long ll;\n" + " unsigned long long ull;\n" + " float f;\n" + " double d;\n" + " long double ld;\n" + " size_t st;\n" + " ptrdiff_t pt;\n" + " intmax_t it;\n" + " uintmax_t ut;\n" + " void * vp;\n" + " scanf(\"%Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf\",\n" + " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, \"str\", L\"str\", foo(), &unknown, unknown);\n" + "}\n"; + std::string result("[test.cpp:23]: (warning) %Lf in format string (no. 1) requires 'long double *' but the argument type is 'bool *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 2) requires 'long double *' but the argument type is 'char *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 3) requires 'long double *' but the argument type is 'signed char *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 4) requires 'long double *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 5) requires 'long double *' but the argument type is 'short *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 6) requires 'long double *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 7) requires 'long double *' but the argument type is 'int *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 8) requires 'long double *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 9) requires 'long double *' but the argument type is 'long *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 10) requires 'long double *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 11) requires 'long double *' but the argument type is 'long long *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 12) requires 'long double *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 13) requires 'long double *' but the argument type is 'float *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 14) requires 'long double *' but the argument type is 'double *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 16) requires 'long double *' but the argument type is 'size_t * {aka unsigned long *}'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 17) requires 'long double *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 18) requires 'long double *' but the argument type is 'intmax_t * {aka long *}'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 19) requires 'long double *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 20) requires 'long double *' but the argument type is 'void * *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 21) requires 'long double *' but the argument type is 'void *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 22) requires 'long double *' but the argument type is 'const char *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 23) requires 'long double *' but the argument type is 'const wchar_t *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 24) requires 'long double *' but the argument type is 'const long double *'.\n"); + std::string result_win64("[test.cpp:23]: (warning) %Lf in format string (no. 1) requires 'long double *' but the argument type is 'bool *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 2) requires 'long double *' but the argument type is 'char *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 3) requires 'long double *' but the argument type is 'signed char *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 4) requires 'long double *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 5) requires 'long double *' but the argument type is 'short *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 6) requires 'long double *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 7) requires 'long double *' but the argument type is 'int *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 8) requires 'long double *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 9) requires 'long double *' but the argument type is 'long *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 10) requires 'long double *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 11) requires 'long double *' but the argument type is 'long long *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 12) requires 'long double *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 13) requires 'long double *' but the argument type is 'float *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 14) requires 'long double *' but the argument type is 'double *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 16) requires 'long double *' but the argument type is 'size_t * {aka unsigned long long *}'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 17) requires 'long double *' but the argument type is 'ptrdiff_t * {aka long long *}'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 18) requires 'long double *' but the argument type is 'intmax_t * {aka long long *}'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 19) requires 'long double *' but the argument type is 'uintmax_t * {aka unsigned long long *}'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 20) requires 'long double *' but the argument type is 'void * *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 21) requires 'long double *' but the argument type is 'void *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 22) requires 'long double *' but the argument type is 'const char *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 23) requires 'long double *' but the argument type is 'const wchar_t *'.\n" + "[test.cpp:23]: (warning) %Lf in format string (no. 24) requires 'long double *' but the argument type is 'const long double *'.\n"); + + check(code, false, false, Settings::Unix32); + ASSERT_EQUALS(result, errout.str()); + check(code, false, false, Settings::Unix64); + ASSERT_EQUALS(result, errout.str()); + check(code, false, false, Settings::Win32A); + ASSERT_EQUALS(result, errout.str()); + check(code, false, false, Settings::Win64); + ASSERT_EQUALS(result_win64, errout.str()); + } + + { + const char * code = "const int * foo() { }\n" + "void foo() {\n" + " bool b;\n" + " char c;\n" + " signed char sc;\n" + " unsigned char uc;\n" + " short s;\n" + " unsigned short us;\n" + " int i;\n" + " unsigned int ui;\n" + " long l;\n" + " unsigned long ul;\n" + " long long ll;\n" + " unsigned long long ull;\n" + " float f;\n" + " double d;\n" + " long double ld;\n" + " size_t st;\n" + " ptrdiff_t pt;\n" + " intmax_t it;\n" + " uintmax_t ut;\n" + " void * vp;\n" + " scanf(\"%n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n %n\",\n" + " &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &pt, &it, &ut, &vp, vp, \"str\", L\"str\", foo(), &unknown, unknown);\n" + "}\n"; + std::string result("[test.cpp:23]: (warning) %n in format string (no. 1) requires 'int *' but the argument type is 'bool *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 2) requires 'int *' but the argument type is 'char *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 3) requires 'int *' but the argument type is 'signed char *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 4) requires 'int *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 5) requires 'int *' but the argument type is 'short *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 6) requires 'int *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 8) requires 'int *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 9) requires 'int *' but the argument type is 'long *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 10) requires 'int *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 11) requires 'int *' but the argument type is 'long long *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 12) requires 'int *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 13) requires 'int *' but the argument type is 'float *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 14) requires 'int *' but the argument type is 'double *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 15) requires 'int *' but the argument type is 'long double *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 16) requires 'int *' but the argument type is 'size_t * {aka unsigned long *}'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 17) requires 'int *' but the argument type is 'ptrdiff_t * {aka long *}'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 18) requires 'int *' but the argument type is 'intmax_t * {aka long *}'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 19) requires 'int *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 20) requires 'int *' but the argument type is 'void * *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 21) requires 'int *' but the argument type is 'void *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 22) requires 'int *' but the argument type is 'const char *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 23) requires 'int *' but the argument type is 'const wchar_t *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 24) requires 'int *' but the argument type is 'const int *'.\n"); + std::string result_win64("[test.cpp:23]: (warning) %n in format string (no. 1) requires 'int *' but the argument type is 'bool *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 2) requires 'int *' but the argument type is 'char *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 3) requires 'int *' but the argument type is 'signed char *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 4) requires 'int *' but the argument type is 'unsigned char *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 5) requires 'int *' but the argument type is 'short *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 6) requires 'int *' but the argument type is 'unsigned short *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 8) requires 'int *' but the argument type is 'unsigned int *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 9) requires 'int *' but the argument type is 'long *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 10) requires 'int *' but the argument type is 'unsigned long *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 11) requires 'int *' but the argument type is 'long long *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 12) requires 'int *' but the argument type is 'unsigned long long *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 13) requires 'int *' but the argument type is 'float *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 14) requires 'int *' but the argument type is 'double *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 15) requires 'int *' but the argument type is 'long double *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 16) requires 'int *' but the argument type is 'size_t * {aka unsigned long long *}'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 17) requires 'int *' but the argument type is 'ptrdiff_t * {aka long long *}'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 18) requires 'int *' but the argument type is 'intmax_t * {aka long long *}'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 19) requires 'int *' but the argument type is 'uintmax_t * {aka unsigned long long *}'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 20) requires 'int *' but the argument type is 'void * *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 21) requires 'int *' but the argument type is 'void *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 22) requires 'int *' but the argument type is 'const char *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 23) requires 'int *' but the argument type is 'const wchar_t *'.\n" + "[test.cpp:23]: (warning) %n in format string (no. 24) requires 'int *' but the argument type is 'const int *'.\n"); + + check(code, false, false, Settings::Unix32); + ASSERT_EQUALS(result, errout.str()); + check(code, false, false, Settings::Unix64); + ASSERT_EQUALS(result, errout.str()); + check(code, false, false, Settings::Win32A); + ASSERT_EQUALS(result, errout.str()); + check(code, false, false, Settings::Win64); + ASSERT_EQUALS(result_win64, errout.str()); + } check("void g() {\n" // #5104 " myvector v1(1);\n" @@ -1459,15 +1914,27 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); - check("void g() {\n" // #5348 - " size_t s1;\n" - " ptrdiff_t s2;\n" - " ssize_t s3;\n" - " scanf(\"%zd\", &s1);\n" - " scanf(\"%zd\", &s2);\n" - " scanf(\"%zd\", &s3);\n" - "}\n"); - ASSERT_EQUALS("[test.cpp:5]: (warning) %zd in format string (no. 1) requires 'ptrdiff_t *' but the argument type is 'size_t * {aka unsigned long *}'.\n", errout.str()); + { + const char * code = "void g() {\n" // #5348 + " size_t s1;\n" + " ptrdiff_t s2;\n" + " ssize_t s3;\n" + " scanf(\"%zd\", &s1);\n" + " scanf(\"%zd\", &s2);\n" + " scanf(\"%zd\", &s3);\n" + "}\n"; + std::string result("[test.cpp:5]: (warning) %zd in format string (no. 1) requires 'ptrdiff_t *' but the argument type is 'size_t * {aka unsigned long *}'.\n"); + std::string result_win64("[test.cpp:5]: (warning) %zd in format string (no. 1) requires 'ptrdiff_t *' but the argument type is 'size_t * {aka unsigned long long *}'.\n"); + + check(code, false, false, Settings::Unix32); + ASSERT_EQUALS(result, errout.str()); + check(code, false, false, Settings::Unix64); + ASSERT_EQUALS(result, errout.str()); + check(code, false, false, Settings::Win32A); + ASSERT_EQUALS(result, errout.str()); + check(code, false, false, Settings::Win64); + ASSERT_EQUALS(result_win64, errout.str()); + } }