Refactor TestIO, split test cases

This commit is contained in:
Daniel Marjamäki 2016-01-12 16:43:27 +01:00
parent 89b23bb698
commit 14670f743e
1 changed files with 271 additions and 433 deletions

View File

@ -725,7 +725,10 @@ private:
((std::string(FORMATSTR) != std::string(TYPE)) \ ((std::string(FORMATSTR) != std::string(TYPE)) \
? "[test.cpp:1]: (warning) " FORMAT " in format string (no. 1) requires '" FORMATSTR " *' but the argument type is '" TYPE " *'.\n" \ ? "[test.cpp:1]: (warning) " FORMAT " in format string (no. 1) requires '" FORMATSTR " *' but the argument type is '" TYPE " *'.\n" \
: "") : "")
#define TEST_SCANF_ERR_AKA(FORMAT,FORMATSTR,TYPE,AKATYPE) "[test.cpp:1]: (warning) " FORMAT " in format string (no. 1) requires '" FORMATSTR " *' but the argument type is '" TYPE " * {aka " AKATYPE " *}'.\n" #define TEST_SCANF_ERR_AKA(FORMAT,FORMATSTR,TYPE,AKATYPE) \
((std::string(FORMATSTR) != std::string(TYPE) && std::string("std::" FORMATSTR) != std::string(TYPE)) \
? "[test.cpp:1]: (warning) " FORMAT " in format string (no. 1) requires '" FORMATSTR " *' but the argument type is '" TYPE " * {aka " AKATYPE " *}'.\n" \
: "")
#define TEST_SCANF_U_ERR(TYPE) TEST_SCANF_ERR("%u", "unsigned int", TYPE) #define TEST_SCANF_U_ERR(TYPE) TEST_SCANF_ERR("%u", "unsigned int", TYPE)
@ -824,6 +827,128 @@ private:
#define TEST_SCANF_HHU_ERR(TYPE) TEST_SCANF_ERR("%hhu", "unsigned char", TYPE)
#define TEST_SCANF_HHU(TYPE) \
check(TEST_SCANF_CODE("%hhu",TYPE), true, false, Settings::Unix32); \
ASSERT_EQUALS(TEST_SCANF_HHU_ERR(TYPE), errout.str()); \
check(TEST_SCANF_CODE("%hhu",TYPE), true, false, Settings::Unix64); \
ASSERT_EQUALS(TEST_SCANF_HHU_ERR(TYPE), errout.str()); \
check(TEST_SCANF_CODE("%hhu",TYPE), true, false, Settings::Win32A); \
ASSERT_EQUALS(TEST_SCANF_HHU_ERR(TYPE), errout.str()); \
check(TEST_SCANF_CODE("%hhu",TYPE), true, false, Settings::Win64); \
ASSERT_EQUALS(TEST_SCANF_HHU_ERR(TYPE), errout.str());
#define TEST_SCANF_HHU_ERR_AKA(TYPE,AKATYPE) TEST_SCANF_ERR_AKA("%hhu", "unsigned char", TYPE, AKATYPE)
#define TEST_SCANF_HHU_AKA(TYPE, AKATYPE, AKATYPE_WIN64) \
check(TEST_SCANF_CODE("%hhu",TYPE), true, false, Settings::Unix32); \
ASSERT_EQUALS(TEST_SCANF_HHU_ERR_AKA(TYPE,AKATYPE), errout.str()); \
check(TEST_SCANF_CODE("%hhu",TYPE), true, false, Settings::Unix64); \
ASSERT_EQUALS(TEST_SCANF_HHU_ERR_AKA(TYPE,AKATYPE), errout.str()); \
check(TEST_SCANF_CODE("%hhu",TYPE), true, false, Settings::Win32A); \
ASSERT_EQUALS(TEST_SCANF_HHU_ERR_AKA(TYPE,AKATYPE), errout.str()); \
check(TEST_SCANF_CODE("%hhu",TYPE), true, false, Settings::Win64); \
ASSERT_EQUALS(TEST_SCANF_HHU_ERR_AKA(TYPE,AKATYPE_WIN64), errout.str());
#define TEST_SCANF_Lu_ERR(TYPE) TEST_SCANF_ERR("%Lu", "unsigned long long", TYPE)
#define TEST_SCANF_Lu(TYPE) \
check(TEST_SCANF_CODE("%Lu",TYPE), true, false, Settings::Unix32); \
ASSERT_EQUALS(TEST_SCANF_Lu_ERR(TYPE), errout.str()); \
check(TEST_SCANF_CODE("%Lu",TYPE), true, false, Settings::Unix64); \
ASSERT_EQUALS(TEST_SCANF_Lu_ERR(TYPE), errout.str()); \
check(TEST_SCANF_CODE("%Lu",TYPE), true, false, Settings::Win32A); \
ASSERT_EQUALS(TEST_SCANF_Lu_ERR(TYPE), errout.str()); \
check(TEST_SCANF_CODE("%Lu",TYPE), true, false, Settings::Win64); \
ASSERT_EQUALS(TEST_SCANF_Lu_ERR(TYPE), errout.str());
#define TEST_SCANF_Lu_ERR_AKA(TYPE,AKATYPE) TEST_SCANF_ERR_AKA("%Lu", "unsigned long long", TYPE, AKATYPE)
#define TEST_SCANF_Lu_AKA(TYPE, AKATYPE, AKATYPE_WIN64) \
check(TEST_SCANF_CODE("%Lu",TYPE), true, false, Settings::Unix32); \
ASSERT_EQUALS(TEST_SCANF_Lu_ERR_AKA(TYPE,AKATYPE), errout.str()); \
check(TEST_SCANF_CODE("%Lu",TYPE), true, false, Settings::Unix64); \
ASSERT_EQUALS(TEST_SCANF_Lu_ERR_AKA(TYPE,AKATYPE), errout.str()); \
check(TEST_SCANF_CODE("%Lu",TYPE), true, false, Settings::Win32A); \
ASSERT_EQUALS(TEST_SCANF_Lu_ERR_AKA(TYPE,AKATYPE), errout.str()); \
check(TEST_SCANF_CODE("%Lu",TYPE), true, false, Settings::Win64); \
ASSERT_EQUALS(TEST_SCANF_Lu_ERR_AKA(TYPE,AKATYPE_WIN64), errout.str());
#define TEST_SCANF_JU_ERR(TYPE) TEST_SCANF_ERR("%ju", "uintmax_t", TYPE)
#define TEST_SCANF_JU(TYPE) \
check(TEST_SCANF_CODE("%ju",TYPE), true, false, Settings::Unix32); \
ASSERT_EQUALS(TEST_SCANF_JU_ERR(TYPE), errout.str()); \
check(TEST_SCANF_CODE("%ju",TYPE), true, false, Settings::Unix64); \
ASSERT_EQUALS(TEST_SCANF_JU_ERR(TYPE), errout.str()); \
check(TEST_SCANF_CODE("%ju",TYPE), true, false, Settings::Win32A); \
ASSERT_EQUALS(TEST_SCANF_JU_ERR(TYPE), errout.str()); \
check(TEST_SCANF_CODE("%ju",TYPE), true, false, Settings::Win64); \
ASSERT_EQUALS(TEST_SCANF_JU_ERR(TYPE), errout.str());
#define TEST_SCANF_JU_ERR_AKA(TYPE,AKATYPE) TEST_SCANF_ERR_AKA("%ju", "uintmax_t", TYPE, AKATYPE)
#define TEST_SCANF_JU_AKA(TYPE, AKATYPE, AKATYPE_WIN64) \
check(TEST_SCANF_CODE("%ju",TYPE), true, false, Settings::Unix32); \
ASSERT_EQUALS(TEST_SCANF_JU_ERR_AKA(TYPE,AKATYPE), errout.str()); \
check(TEST_SCANF_CODE("%ju",TYPE), true, false, Settings::Unix64); \
ASSERT_EQUALS(TEST_SCANF_JU_ERR_AKA(TYPE,AKATYPE), errout.str()); \
check(TEST_SCANF_CODE("%ju",TYPE), true, false, Settings::Win32A); \
ASSERT_EQUALS(TEST_SCANF_JU_ERR_AKA(TYPE,AKATYPE), errout.str()); \
check(TEST_SCANF_CODE("%ju",TYPE), true, false, Settings::Win64); \
ASSERT_EQUALS(TEST_SCANF_JU_ERR_AKA(TYPE,AKATYPE_WIN64), errout.str());
#define TEST_SCANF_ZU_ERR(TYPE) TEST_SCANF_ERR("%zu", "size_t", TYPE)
#define TEST_SCANF_ZU(TYPE) \
check(TEST_SCANF_CODE("%zu",TYPE), true, false, Settings::Unix32); \
ASSERT_EQUALS(TEST_SCANF_ZU_ERR(TYPE), errout.str()); \
check(TEST_SCANF_CODE("%zu",TYPE), true, false, Settings::Unix64); \
ASSERT_EQUALS(TEST_SCANF_ZU_ERR(TYPE), errout.str()); \
check(TEST_SCANF_CODE("%zu",TYPE), true, false, Settings::Win32A); \
ASSERT_EQUALS(TEST_SCANF_ZU_ERR(TYPE), errout.str()); \
check(TEST_SCANF_CODE("%zu",TYPE), true, false, Settings::Win64); \
ASSERT_EQUALS(TEST_SCANF_ZU_ERR(TYPE), errout.str());
#define TEST_SCANF_ZU_ERR_AKA(TYPE,AKATYPE) TEST_SCANF_ERR_AKA("%zu", "size_t", TYPE, AKATYPE)
#define TEST_SCANF_ZU_AKA(TYPE, AKATYPE, AKATYPE_WIN64) \
check(TEST_SCANF_CODE("%zu",TYPE), true, false, Settings::Unix32); \
ASSERT_EQUALS(TEST_SCANF_ZU_ERR_AKA(TYPE,AKATYPE), errout.str()); \
check(TEST_SCANF_CODE("%zu",TYPE), true, false, Settings::Unix64); \
ASSERT_EQUALS(TEST_SCANF_ZU_ERR_AKA(TYPE,AKATYPE), errout.str()); \
check(TEST_SCANF_CODE("%zu",TYPE), true, false, Settings::Win32A); \
ASSERT_EQUALS(TEST_SCANF_ZU_ERR_AKA(TYPE,AKATYPE), errout.str()); \
check(TEST_SCANF_CODE("%zu",TYPE), true, false, Settings::Win64); \
ASSERT_EQUALS(TEST_SCANF_ZU_ERR_AKA(TYPE,AKATYPE_WIN64), errout.str());
#define TEST_SCANF_TU_ERR(TYPE) TEST_SCANF_ERR("%tu", "unsigned ptrdiff_t", TYPE)
#define TEST_SCANF_TU(TYPE) \
check(TEST_SCANF_CODE("%tu",TYPE), true, false, Settings::Unix32); \
ASSERT_EQUALS(TEST_SCANF_TU_ERR(TYPE), errout.str()); \
check(TEST_SCANF_CODE("%tu",TYPE), true, false, Settings::Unix64); \
ASSERT_EQUALS(TEST_SCANF_TU_ERR(TYPE), errout.str()); \
check(TEST_SCANF_CODE("%tu",TYPE), true, false, Settings::Win32A); \
ASSERT_EQUALS(TEST_SCANF_TU_ERR(TYPE), errout.str()); \
check(TEST_SCANF_CODE("%tu",TYPE), true, false, Settings::Win64); \
ASSERT_EQUALS(TEST_SCANF_TU_ERR(TYPE), errout.str());
#define TEST_SCANF_TU_ERR_AKA(TYPE,AKATYPE) TEST_SCANF_ERR_AKA("%tu", "unsigned ptrdiff_t", TYPE, AKATYPE)
#define TEST_SCANF_TU_AKA(TYPE, AKATYPE, AKATYPE_WIN64) \
check(TEST_SCANF_CODE("%tu",TYPE), true, false, Settings::Unix32); \
ASSERT_EQUALS(TEST_SCANF_TU_ERR_AKA(TYPE,AKATYPE), errout.str()); \
check(TEST_SCANF_CODE("%tu",TYPE), true, false, Settings::Unix64); \
ASSERT_EQUALS(TEST_SCANF_TU_ERR_AKA(TYPE,AKATYPE), errout.str()); \
check(TEST_SCANF_CODE("%tu",TYPE), true, false, Settings::Win32A); \
ASSERT_EQUALS(TEST_SCANF_TU_ERR_AKA(TYPE,AKATYPE), errout.str()); \
check(TEST_SCANF_CODE("%tu",TYPE), true, false, Settings::Win64); \
ASSERT_EQUALS(TEST_SCANF_TU_ERR_AKA(TYPE,AKATYPE_WIN64), errout.str());
void testScanfArgument() { void testScanfArgument() {
check("void foo() {\n" check("void foo() {\n"
" scanf(\"%1d\", &foo);\n" " scanf(\"%1d\", &foo);\n"
@ -1008,442 +1133,155 @@ private:
TEST_SCANF_HU_AKA("std::intptr_t", "long", "long long"); TEST_SCANF_HU_AKA("std::intptr_t", "long", "long long");
TEST_SCANF_HU_AKA("std::uintptr_t", "unsigned long", "unsigned long long"); TEST_SCANF_HU_AKA("std::uintptr_t", "unsigned long", "unsigned long long");
{ TEST_SCANF_HHU("bool");
const char * code = "void foo() {\n" TEST_SCANF_HHU("char");
" bool b;\n" TEST_SCANF_HHU("signed char");
" char c;\n" TEST_SCANF_HHU("unsigned char");
" signed char sc;\n" TEST_SCANF_HHU("short");
" unsigned char uc;\n" TEST_SCANF_HHU("signed short");
" short s;\n" TEST_SCANF_HHU("unsigned short");
" unsigned short us;\n" TEST_SCANF_HHU("int");
" int i;\n" TEST_SCANF_HHU("signed int");
" unsigned int ui;\n" TEST_SCANF_HHU("long");
" long l;\n" TEST_SCANF_HHU("signed long");
" unsigned long ul;\n" TEST_SCANF_HHU("unsigned long");
" long long ll;\n" TEST_SCANF_HHU("long long");
" unsigned long long ull;\n" TEST_SCANF_HHU("signed long long");
" float f;\n" TEST_SCANF_HHU("unsigned long long");
" double d;\n" TEST_SCANF_HHU("float");
" long double ld;\n" TEST_SCANF_HHU("double");
" size_t st;\n" TEST_SCANF_HHU("long double");
" ssize_t sst;\n" TEST_SCANF_HHU_AKA("size_t", "unsigned long", "unsigned long long");
" ptrdiff_t pt;\n" TEST_SCANF_HHU_AKA("ssize_t", "long", "long long");
" intmax_t it;\n" TEST_SCANF_HHU_AKA("ptrdiff_t", "long", "long long");
" uintmax_t ut;\n" TEST_SCANF_HHU_AKA("intmax_t", "long", "long long");
" void * vp;\n" TEST_SCANF_HHU_AKA("uintmax_t", "unsigned long", "unsigned long long");
" std::size_t stdst;\n" TEST_SCANF_HHU("void *");
" std::ssize_t stdsst;\n" TEST_SCANF_HHU_AKA("std::size_t", "unsigned long", "unsigned long long");
" std::ptrdiff_t stdpt;\n" TEST_SCANF_HHU_AKA("std::ssize_t", "long", "long long");
" std::intptr_t stdipt;\n" TEST_SCANF_HHU_AKA("std::ptrdiff_t", "long", "long long");
" std::uintptr_t stduipt;\n" TEST_SCANF_HHU_AKA("std::intptr_t", "long", "long long");
" scanf(\"%hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu\",\n" TEST_SCANF_HHU_AKA("std::uintptr_t", "unsigned long", "unsigned long long");
" &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &sst, &pt, &it, &ut, &vp, vp,\n"
" &unknown, unknown, &stdst, &stdsst, &stdpt, &stdipt, &stduipt);\n"
"}\n";
std::string result("[test.cpp:28]: (warning) %hhu in format string (no. 1) requires 'unsigned char *' but the argument type is 'bool *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 2) requires 'unsigned char *' but the argument type is 'char *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 3) requires 'unsigned char *' but the argument type is 'signed char *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 5) requires 'unsigned char *' but the argument type is 'short *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 6) requires 'unsigned char *' but the argument type is 'unsigned short *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 7) requires 'unsigned char *' but the argument type is 'int *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 8) requires 'unsigned char *' but the argument type is 'unsigned int *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 9) requires 'unsigned char *' but the argument type is 'long *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 10) requires 'unsigned char *' but the argument type is 'unsigned long *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 11) requires 'unsigned char *' but the argument type is 'long long *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 12) requires 'unsigned char *' but the argument type is 'unsigned long long *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 13) requires 'unsigned char *' but the argument type is 'float *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 14) requires 'unsigned char *' but the argument type is 'double *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 15) requires 'unsigned char *' but the argument type is 'long double *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 16) requires 'unsigned char *' but the argument type is 'size_t * {aka unsigned long *}'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 17) requires 'unsigned char *' but the argument type is 'ssize_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 18) requires 'unsigned char *' but the argument type is 'ptrdiff_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 19) requires 'unsigned char *' but the argument type is 'intmax_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 20) requires 'unsigned char *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 21) requires 'unsigned char *' but the argument type is 'void * *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 22) requires 'unsigned char *' but the argument type is 'void *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 25) requires 'unsigned char *' but the argument type is 'std::size_t * {aka unsigned long *}'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 26) requires 'unsigned char *' but the argument type is 'std::ssize_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 27) requires 'unsigned char *' but the argument type is 'std::ptrdiff_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 28) requires 'unsigned char *' but the argument type is 'std::intptr_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 29) requires 'unsigned char *' but the argument type is 'std::uintptr_t * {aka unsigned long *}'.\n");
std::string result_win64("[test.cpp:28]: (warning) %hhu in format string (no. 1) requires 'unsigned char *' but the argument type is 'bool *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 2) requires 'unsigned char *' but the argument type is 'char *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 3) requires 'unsigned char *' but the argument type is 'signed char *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 5) requires 'unsigned char *' but the argument type is 'short *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 6) requires 'unsigned char *' but the argument type is 'unsigned short *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 7) requires 'unsigned char *' but the argument type is 'int *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 8) requires 'unsigned char *' but the argument type is 'unsigned int *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 9) requires 'unsigned char *' but the argument type is 'long *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 10) requires 'unsigned char *' but the argument type is 'unsigned long *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 11) requires 'unsigned char *' but the argument type is 'long long *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 12) requires 'unsigned char *' but the argument type is 'unsigned long long *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 13) requires 'unsigned char *' but the argument type is 'float *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 14) requires 'unsigned char *' but the argument type is 'double *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 15) requires 'unsigned char *' but the argument type is 'long double *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 16) requires 'unsigned char *' but the argument type is 'size_t * {aka unsigned long long *}'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 17) requires 'unsigned char *' but the argument type is 'ssize_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 18) requires 'unsigned char *' but the argument type is 'ptrdiff_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 19) requires 'unsigned char *' but the argument type is 'intmax_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 20) requires 'unsigned char *' but the argument type is 'uintmax_t * {aka unsigned long long *}'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 21) requires 'unsigned char *' but the argument type is 'void * *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 22) requires 'unsigned char *' but the argument type is 'void *'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 25) requires 'unsigned char *' but the argument type is 'std::size_t * {aka unsigned long long *}'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 26) requires 'unsigned char *' but the argument type is 'std::ssize_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 27) requires 'unsigned char *' but the argument type is 'std::ptrdiff_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 28) requires 'unsigned char *' but the argument type is 'std::intptr_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %hhu in format string (no. 29) requires 'unsigned char *' but the argument type is 'std::uintptr_t * {aka unsigned long long *}'.\n");
check(code, true, false, Settings::Unix32); TEST_SCANF_Lu("bool");
ASSERT_EQUALS(result, errout.str()); TEST_SCANF_Lu("char");
check(code, true, false, Settings::Unix64); TEST_SCANF_Lu("signed char");
ASSERT_EQUALS(result, errout.str()); TEST_SCANF_Lu("unsigned char");
check(code, true, false, Settings::Win32A); TEST_SCANF_Lu("short");
ASSERT_EQUALS(result, errout.str()); TEST_SCANF_Lu("signed short");
check(code, true, false, Settings::Win64); TEST_SCANF_Lu("unsigned short");
ASSERT_EQUALS(result_win64, errout.str()); TEST_SCANF_Lu("int");
} TEST_SCANF_Lu("signed int");
TEST_SCANF_Lu("long");
TEST_SCANF_Lu("signed long");
TEST_SCANF_Lu("unsigned long");
TEST_SCANF_Lu("long long");
TEST_SCANF_Lu("signed long long");
TEST_SCANF_Lu("unsigned long long");
TEST_SCANF_Lu("float");
TEST_SCANF_Lu("double");
TEST_SCANF_Lu("long double");
TEST_SCANF_Lu_AKA("size_t", "unsigned long", "unsigned long long");
TEST_SCANF_Lu_AKA("ssize_t", "long", "long long");
TEST_SCANF_Lu_AKA("ptrdiff_t", "long", "long long");
TEST_SCANF_Lu_AKA("intmax_t", "long", "long long");
TEST_SCANF_Lu_AKA("uintmax_t", "unsigned long", "unsigned long long");
TEST_SCANF_Lu("void *");
TEST_SCANF_Lu_AKA("std::size_t", "unsigned long", "unsigned long long");
TEST_SCANF_Lu_AKA("std::ssize_t", "long", "long long");
TEST_SCANF_Lu_AKA("std::ptrdiff_t", "long", "long long");
TEST_SCANF_Lu_AKA("std::intptr_t", "long", "long long");
// TODO TEST_SCANF_Lu_AKA("std::uintptr_t", "unsigned long", "unsigned long long");
{ TEST_SCANF_JU("bool");
const char * code = "void foo() {\n" TEST_SCANF_JU("char");
" bool b;\n" TEST_SCANF_JU("signed char");
" char c;\n" TEST_SCANF_JU("unsigned char");
" signed char sc;\n" TEST_SCANF_JU("short");
" unsigned char uc;\n" TEST_SCANF_JU("signed short");
" short s;\n" TEST_SCANF_JU("unsigned short");
" unsigned short us;\n" TEST_SCANF_JU("int");
" int i;\n" TEST_SCANF_JU("signed int");
" unsigned int ui;\n" TEST_SCANF_JU("long");
" long l;\n" TEST_SCANF_JU("signed long");
" unsigned long ul;\n" TEST_SCANF_JU("unsigned long");
" long long ll;\n" TEST_SCANF_JU("long long");
" unsigned long long ull;\n" TEST_SCANF_JU("signed long long");
" float f;\n" TEST_SCANF_JU("unsigned long long");
" double d;\n" TEST_SCANF_JU("float");
" long double ld;\n" TEST_SCANF_JU("double");
" size_t st;\n" TEST_SCANF_JU("long double");
" ssize_t sst;\n" TEST_SCANF_JU_AKA("size_t", "unsigned long", "unsigned long long");
" ptrdiff_t pt;\n" TEST_SCANF_JU_AKA("ssize_t", "long", "long long");
" intmax_t it;\n" TEST_SCANF_JU_AKA("ptrdiff_t", "long", "long long");
" uintmax_t ut;\n" TEST_SCANF_JU_AKA("intmax_t", "long", "long long");
" void * vp;\n" TEST_SCANF_JU_AKA("uintmax_t", "unsigned long", "unsigned long long");
" std::size_t stdst;\n" TEST_SCANF_JU("void *");
" std::ssize_t stdsst;\n" TEST_SCANF_JU_AKA("std::size_t", "unsigned long", "unsigned long long");
" std::ptrdiff_t stdpt;\n" TEST_SCANF_JU_AKA("std::ssize_t", "long", "long long");
" std::intptr_t stdipt;\n" TEST_SCANF_JU_AKA("std::ptrdiff_t", "long", "long long");
" std::uintptr_t stduipt;\n" TEST_SCANF_JU_AKA("std::intptr_t", "long", "long long");
" scanf(\"%Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu\",\n" TEST_SCANF_JU_AKA("std::uintptr_t", "unsigned long", "unsigned long long");
" &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &sst, &pt, &it, &ut, &vp, vp,\n"
" &unknown, unknown, &stdst, &stdsst, &stdpt, &stdipt, &stduipt);\n"
"}\n";
std::string result("[test.cpp:28]: (warning) %Lu in format string (no. 1) requires 'unsigned long long *' but the argument type is 'bool *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 2) requires 'unsigned long long *' but the argument type is 'char *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 3) requires 'unsigned long long *' but the argument type is 'signed char *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 4) requires 'unsigned long long *' but the argument type is 'unsigned char *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 5) requires 'unsigned long long *' but the argument type is 'short *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 6) requires 'unsigned long long *' but the argument type is 'unsigned short *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 7) requires 'unsigned long long *' but the argument type is 'int *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 8) requires 'unsigned long long *' but the argument type is 'unsigned int *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 9) requires 'unsigned long long *' but the argument type is 'long *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 10) requires 'unsigned long long *' but the argument type is 'unsigned long *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 11) requires 'unsigned long long *' but the argument type is 'long long *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 13) requires 'unsigned long long *' but the argument type is 'float *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 14) requires 'unsigned long long *' but the argument type is 'double *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 15) requires 'unsigned long long *' but the argument type is 'long double *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 16) requires 'unsigned long long *' but the argument type is 'size_t * {aka unsigned long *}'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 17) requires 'unsigned long long *' but the argument type is 'ssize_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 18) requires 'unsigned long long *' but the argument type is 'ptrdiff_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 19) requires 'unsigned long long *' but the argument type is 'intmax_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 20) requires 'unsigned long long *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 21) requires 'unsigned long long *' but the argument type is 'void * *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 22) requires 'unsigned long long *' but the argument type is 'void *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 25) requires 'unsigned long long *' but the argument type is 'std::size_t * {aka unsigned long *}'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 26) requires 'unsigned long long *' but the argument type is 'std::ssize_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 27) requires 'unsigned long long *' but the argument type is 'std::ptrdiff_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 28) requires 'unsigned long long *' but the argument type is 'std::intptr_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 29) requires 'unsigned long long *' but the argument type is 'std::uintptr_t * {aka unsigned long *}'.\n");
std::string result_win64("[test.cpp:28]: (warning) %Lu in format string (no. 1) requires 'unsigned long long *' but the argument type is 'bool *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 2) requires 'unsigned long long *' but the argument type is 'char *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 3) requires 'unsigned long long *' but the argument type is 'signed char *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 4) requires 'unsigned long long *' but the argument type is 'unsigned char *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 5) requires 'unsigned long long *' but the argument type is 'short *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 6) requires 'unsigned long long *' but the argument type is 'unsigned short *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 7) requires 'unsigned long long *' but the argument type is 'int *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 8) requires 'unsigned long long *' but the argument type is 'unsigned int *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 9) requires 'unsigned long long *' but the argument type is 'long *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 10) requires 'unsigned long long *' but the argument type is 'unsigned long *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 11) requires 'unsigned long long *' but the argument type is 'long long *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 13) requires 'unsigned long long *' but the argument type is 'float *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 14) requires 'unsigned long long *' but the argument type is 'double *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 15) requires 'unsigned long long *' but the argument type is 'long double *'.\n"
"[test.cpp:28]: (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:28]: (warning) %Lu in format string (no. 17) requires 'unsigned long long *' but the argument type is 'ssize_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 18) requires 'unsigned long long *' but the argument type is 'ptrdiff_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 19) requires 'unsigned long long *' but the argument type is 'intmax_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 20) requires 'unsigned long long *' but the argument type is 'uintmax_t * {aka unsigned long long *}'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 21) requires 'unsigned long long *' but the argument type is 'void * *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 22) requires 'unsigned long long *' but the argument type is 'void *'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 25) requires 'unsigned long long *' but the argument type is 'std::size_t * {aka unsigned long long *}'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 26) requires 'unsigned long long *' but the argument type is 'std::ssize_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 27) requires 'unsigned long long *' but the argument type is 'std::ptrdiff_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %Lu in format string (no. 28) requires 'unsigned long long *' but the argument type is 'std::intptr_t * {aka long long *}'.\n");
check(code, true, false, Settings::Unix32); TEST_SCANF_ZU("bool");
ASSERT_EQUALS(result, errout.str()); TEST_SCANF_ZU("char");
check(code, true, false, Settings::Unix64); TEST_SCANF_ZU("signed char");
ASSERT_EQUALS(result, errout.str()); TEST_SCANF_ZU("unsigned char");
check(code, true, false, Settings::Win32A); TEST_SCANF_ZU("short");
ASSERT_EQUALS(result, errout.str()); TEST_SCANF_ZU("signed short");
check(code, true, false, Settings::Win64); TEST_SCANF_ZU("unsigned short");
ASSERT_EQUALS(result_win64, errout.str()); TEST_SCANF_ZU("int");
} TEST_SCANF_ZU("signed int");
TEST_SCANF_ZU("long");
TEST_SCANF_ZU("signed long");
TEST_SCANF_ZU("unsigned long");
TEST_SCANF_ZU("long long");
TEST_SCANF_ZU("signed long long");
TEST_SCANF_ZU("unsigned long long");
TEST_SCANF_ZU("float");
TEST_SCANF_ZU("double");
TEST_SCANF_ZU("long double");
TEST_SCANF_ZU_AKA("size_t", "unsigned long", "unsigned long long");
TEST_SCANF_ZU_AKA("ssize_t", "long", "long long");
TEST_SCANF_ZU_AKA("ptrdiff_t", "long", "long long");
TEST_SCANF_ZU_AKA("intmax_t", "long", "long long");
TEST_SCANF_ZU_AKA("uintmax_t", "unsigned long", "unsigned long long");
TEST_SCANF_ZU("void *");
TEST_SCANF_ZU_AKA("std::size_t", "unsigned long", "unsigned long long");
TEST_SCANF_ZU_AKA("std::ssize_t", "long", "long long");
TEST_SCANF_ZU_AKA("std::ptrdiff_t", "long", "long long");
TEST_SCANF_ZU_AKA("std::intptr_t", "long", "long long");
TEST_SCANF_ZU_AKA("std::uintptr_t", "unsigned long", "unsigned long long");
{ TEST_SCANF_TU("bool");
const char * code = "void foo() {\n" TEST_SCANF_TU("char");
" bool b;\n" TEST_SCANF_TU("signed char");
" char c;\n" TEST_SCANF_TU("unsigned char");
" signed char sc;\n" TEST_SCANF_TU("short");
" unsigned char uc;\n" TEST_SCANF_TU("signed short");
" short s;\n" TEST_SCANF_TU("unsigned short");
" unsigned short us;\n" TEST_SCANF_TU("int");
" int i;\n" TEST_SCANF_TU("signed int");
" unsigned int ui;\n" TEST_SCANF_TU("long");
" long l;\n" TEST_SCANF_TU("signed long");
" unsigned long ul;\n" TEST_SCANF_TU("unsigned long");
" long long ll;\n" TEST_SCANF_TU("long long");
" unsigned long long ull;\n" TEST_SCANF_TU("signed long long");
" float f;\n" TEST_SCANF_TU("unsigned long long");
" double d;\n" TEST_SCANF_TU("float");
" long double ld;\n" TEST_SCANF_TU("double");
" size_t st;\n" TEST_SCANF_TU("long double");
" ssize_t sst;\n" TEST_SCANF_TU_AKA("size_t", "unsigned long", "unsigned long long");
" ptrdiff_t pt;\n" TEST_SCANF_TU_AKA("ssize_t", "long", "long long");
" intmax_t it;\n" TEST_SCANF_TU_AKA("ptrdiff_t", "long", "long long");
" uintmax_t ut;\n" TEST_SCANF_TU_AKA("intmax_t", "long", "long long");
" void * vp;\n" TEST_SCANF_TU_AKA("uintmax_t", "unsigned long", "unsigned long long");
" std::size_t stdst;\n" TEST_SCANF_TU("void *");
" std::ssize_t stdsst;\n" TEST_SCANF_TU_AKA("std::size_t", "unsigned long", "unsigned long long");
" std::ptrdiff_t stdpt;\n" TEST_SCANF_TU_AKA("std::ssize_t", "long", "long long");
" std::intptr_t stdipt;\n" TEST_SCANF_TU_AKA("std::ptrdiff_t", "long", "long long");
" std::uintptr_t stduipt;\n" TEST_SCANF_TU_AKA("std::intptr_t", "long", "long long");
" scanf(\"%ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju %ju\",\n" TEST_SCANF_TU_AKA("std::uintptr_t", "unsigned long", "unsigned long long");
" &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &sst, &pt, &it, &ut, &vp, vp,\n"
" &unknown, unknown, &stdst, &stdsst, &stdpt, &stdipt, &stduipt);\n"
"}\n";
std::string result("[test.cpp:28]: (warning) %ju in format string (no. 1) requires 'uintmax_t *' but the argument type is 'bool *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 2) requires 'uintmax_t *' but the argument type is 'char *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 3) requires 'uintmax_t *' but the argument type is 'signed char *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 4) requires 'uintmax_t *' but the argument type is 'unsigned char *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 5) requires 'uintmax_t *' but the argument type is 'short *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 6) requires 'uintmax_t *' but the argument type is 'unsigned short *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 7) requires 'uintmax_t *' but the argument type is 'int *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 8) requires 'uintmax_t *' but the argument type is 'unsigned int *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 9) requires 'uintmax_t *' but the argument type is 'long *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 10) requires 'uintmax_t *' but the argument type is 'unsigned long *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 11) requires 'uintmax_t *' but the argument type is 'long long *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 12) requires 'uintmax_t *' but the argument type is 'unsigned long long *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 13) requires 'uintmax_t *' but the argument type is 'float *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 14) requires 'uintmax_t *' but the argument type is 'double *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 15) requires 'uintmax_t *' but the argument type is 'long double *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 16) requires 'uintmax_t *' but the argument type is 'size_t * {aka unsigned long *}'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 17) requires 'uintmax_t *' but the argument type is 'ssize_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 18) requires 'uintmax_t *' but the argument type is 'ptrdiff_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 19) requires 'uintmax_t *' but the argument type is 'intmax_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 21) requires 'uintmax_t *' but the argument type is 'void * *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 22) requires 'uintmax_t *' but the argument type is 'void *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 25) requires 'uintmax_t *' but the argument type is 'std::size_t * {aka unsigned long *}'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 26) requires 'uintmax_t *' but the argument type is 'std::ssize_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 27) requires 'uintmax_t *' but the argument type is 'std::ptrdiff_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 28) requires 'uintmax_t *' but the argument type is 'std::intptr_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 29) requires 'uintmax_t *' but the argument type is 'std::uintptr_t * {aka unsigned long *}'.\n");
std::string result_win64("[test.cpp:28]: (warning) %ju in format string (no. 1) requires 'uintmax_t *' but the argument type is 'bool *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 2) requires 'uintmax_t *' but the argument type is 'char *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 3) requires 'uintmax_t *' but the argument type is 'signed char *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 4) requires 'uintmax_t *' but the argument type is 'unsigned char *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 5) requires 'uintmax_t *' but the argument type is 'short *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 6) requires 'uintmax_t *' but the argument type is 'unsigned short *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 7) requires 'uintmax_t *' but the argument type is 'int *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 8) requires 'uintmax_t *' but the argument type is 'unsigned int *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 9) requires 'uintmax_t *' but the argument type is 'long *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 10) requires 'uintmax_t *' but the argument type is 'unsigned long *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 11) requires 'uintmax_t *' but the argument type is 'long long *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 12) requires 'uintmax_t *' but the argument type is 'unsigned long long *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 13) requires 'uintmax_t *' but the argument type is 'float *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 14) requires 'uintmax_t *' but the argument type is 'double *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 15) requires 'uintmax_t *' but the argument type is 'long double *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 16) requires 'uintmax_t *' but the argument type is 'size_t * {aka unsigned long long *}'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 17) requires 'uintmax_t *' but the argument type is 'ssize_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 18) requires 'uintmax_t *' but the argument type is 'ptrdiff_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 19) requires 'uintmax_t *' but the argument type is 'intmax_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 21) requires 'uintmax_t *' but the argument type is 'void * *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 22) requires 'uintmax_t *' but the argument type is 'void *'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 25) requires 'uintmax_t *' but the argument type is 'std::size_t * {aka unsigned long long *}'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 26) requires 'uintmax_t *' but the argument type is 'std::ssize_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 27) requires 'uintmax_t *' but the argument type is 'std::ptrdiff_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 28) requires 'uintmax_t *' but the argument type is 'std::intptr_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %ju in format string (no. 29) requires 'uintmax_t *' but the argument type is 'std::uintptr_t * {aka unsigned long long *}'.\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"
" ssize_t sst;\n"
" ptrdiff_t pt;\n"
" intmax_t it;\n"
" uintmax_t ut;\n"
" void * vp;\n"
" std::size_t stdst;\n"
" std::ssize_t stdsst;\n"
" std::ptrdiff_t stdpt;\n"
" std::intptr_t stdipt;\n"
" std::uintptr_t stduipt;\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 %zu %zu %zu %zu %zu %zu\",\n"
" &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &sst, &pt, &it, &ut, &vp, vp,\n"
" &unknown, unknown, &stdst, &stdsst, &stdpt, &stdipt, &stduipt);\n"
"}\n";
std::string result("[test.cpp:28]: (warning) %zu in format string (no. 1) requires 'size_t *' but the argument type is 'bool *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 2) requires 'size_t *' but the argument type is 'char *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 3) requires 'size_t *' but the argument type is 'signed char *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 4) requires 'size_t *' but the argument type is 'unsigned char *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 5) requires 'size_t *' but the argument type is 'short *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 6) requires 'size_t *' but the argument type is 'unsigned short *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 7) requires 'size_t *' but the argument type is 'int *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 8) requires 'size_t *' but the argument type is 'unsigned int *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 9) requires 'size_t *' but the argument type is 'long *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 10) requires 'size_t *' but the argument type is 'unsigned long *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 11) requires 'size_t *' but the argument type is 'long long *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 12) requires 'size_t *' but the argument type is 'unsigned long long *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 13) requires 'size_t *' but the argument type is 'float *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 14) requires 'size_t *' but the argument type is 'double *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 15) requires 'size_t *' but the argument type is 'long double *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 17) requires 'size_t *' but the argument type is 'ssize_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 18) requires 'size_t *' but the argument type is 'ptrdiff_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 19) requires 'size_t *' but the argument type is 'intmax_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 20) requires 'size_t *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 21) requires 'size_t *' but the argument type is 'void * *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 22) requires 'size_t *' but the argument type is 'void *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 26) requires 'size_t *' but the argument type is 'std::ssize_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 27) requires 'size_t *' but the argument type is 'std::ptrdiff_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 28) requires 'size_t *' but the argument type is 'std::intptr_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 29) requires 'size_t *' but the argument type is 'std::uintptr_t * {aka unsigned long *}'.\n");
std::string result_win64("[test.cpp:28]: (warning) %zu in format string (no. 1) requires 'size_t *' but the argument type is 'bool *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 2) requires 'size_t *' but the argument type is 'char *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 3) requires 'size_t *' but the argument type is 'signed char *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 4) requires 'size_t *' but the argument type is 'unsigned char *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 5) requires 'size_t *' but the argument type is 'short *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 6) requires 'size_t *' but the argument type is 'unsigned short *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 7) requires 'size_t *' but the argument type is 'int *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 8) requires 'size_t *' but the argument type is 'unsigned int *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 9) requires 'size_t *' but the argument type is 'long *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 10) requires 'size_t *' but the argument type is 'unsigned long *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 11) requires 'size_t *' but the argument type is 'long long *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 12) requires 'size_t *' but the argument type is 'unsigned long long *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 13) requires 'size_t *' but the argument type is 'float *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 14) requires 'size_t *' but the argument type is 'double *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 15) requires 'size_t *' but the argument type is 'long double *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 17) requires 'size_t *' but the argument type is 'ssize_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 18) requires 'size_t *' but the argument type is 'ptrdiff_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 19) requires 'size_t *' but the argument type is 'intmax_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 20) requires 'size_t *' but the argument type is 'uintmax_t * {aka unsigned long long *}'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 21) requires 'size_t *' but the argument type is 'void * *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 22) requires 'size_t *' but the argument type is 'void *'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 26) requires 'size_t *' but the argument type is 'std::ssize_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 27) requires 'size_t *' but the argument type is 'std::ptrdiff_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 28) requires 'size_t *' but the argument type is 'std::intptr_t * {aka long long *}'.\n"
"[test.cpp:28]: (warning) %zu in format string (no. 29) requires 'size_t *' but the argument type is 'std::uintptr_t * {aka unsigned long long *}'.\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"
" 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"
" ssize_t sst;\n"
" ptrdiff_t pt;\n"
" intmax_t it;\n"
" uintmax_t ut;\n"
" void * vp;\n"
" std::size_t stdst;\n"
" std::ssize_t stdsst;\n"
" std::ptrdiff_t stdpt;\n"
" std::intptr_t stdipt;\n"
" std::uintptr_t stduipt;\n"
" scanf(\"%tu %tu %tu %tu %tu %tu %tu %tu %tu %tu %tu %tu %tu %tu %tu %tu %tu %tu %tu %tu %tu %tu %tu %tu %tu %tu %tu %tu %tu\",\n"
" &b, &c, &sc, &uc, &s, &us, &i, &ui, &l, &ul, &ll, &ull, &f, &d, &ld, &st, &sst, &pt, &it, &ut, &vp, vp,\n"
" &unknown, unknown, &stdst, &stdsst, &stdpt, &stdipt, &stduipt);\n"
"}\n", false, false, Settings::Unix64);
ASSERT_EQUALS("[test.cpp:28]: (warning) %tu in format string (no. 1) requires 'unsigned ptrdiff_t *' but the argument type is 'bool *'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 2) requires 'unsigned ptrdiff_t *' but the argument type is 'char *'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 3) requires 'unsigned ptrdiff_t *' but the argument type is 'signed char *'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 4) requires 'unsigned ptrdiff_t *' but the argument type is 'unsigned char *'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 5) requires 'unsigned ptrdiff_t *' but the argument type is 'short *'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 6) requires 'unsigned ptrdiff_t *' but the argument type is 'unsigned short *'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 7) requires 'unsigned ptrdiff_t *' but the argument type is 'int *'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 8) requires 'unsigned ptrdiff_t *' but the argument type is 'unsigned int *'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 9) requires 'unsigned ptrdiff_t *' but the argument type is 'long *'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 10) requires 'unsigned ptrdiff_t *' but the argument type is 'unsigned long *'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 11) requires 'unsigned ptrdiff_t *' but the argument type is 'long long *'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 12) requires 'unsigned ptrdiff_t *' but the argument type is 'unsigned long long *'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 13) requires 'unsigned ptrdiff_t *' but the argument type is 'float *'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 14) requires 'unsigned ptrdiff_t *' but the argument type is 'double *'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 15) requires 'unsigned ptrdiff_t *' but the argument type is 'long double *'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 16) requires 'unsigned ptrdiff_t *' but the argument type is 'size_t * {aka unsigned long *}'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 17) requires 'unsigned ptrdiff_t *' but the argument type is 'ssize_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 18) requires 'unsigned ptrdiff_t *' but the argument type is 'ptrdiff_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 19) requires 'unsigned ptrdiff_t *' but the argument type is 'intmax_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 20) requires 'unsigned ptrdiff_t *' but the argument type is 'uintmax_t * {aka unsigned long *}'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 21) requires 'unsigned ptrdiff_t *' but the argument type is 'void * *'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 22) requires 'unsigned ptrdiff_t *' but the argument type is 'void *'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 25) requires 'unsigned ptrdiff_t *' but the argument type is 'std::size_t * {aka unsigned long *}'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 26) requires 'unsigned ptrdiff_t *' but the argument type is 'std::ssize_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 27) requires 'unsigned ptrdiff_t *' but the argument type is 'std::ptrdiff_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 28) requires 'unsigned ptrdiff_t *' but the argument type is 'std::intptr_t * {aka long *}'.\n"
"[test.cpp:28]: (warning) %tu in format string (no. 29) requires 'unsigned ptrdiff_t *' but the argument type is 'std::uintptr_t * {aka unsigned long *}'.\n", errout.str());
check("void foo() {\n" check("void foo() {\n"
" bool b;\n" " bool b;\n"