diff --git a/test/testio.cpp b/test/testio.cpp index f2052d899..ccb5cbb0a 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -725,7 +725,10 @@ private: ((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" \ : "") -#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) @@ -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() { check("void 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::uintptr_t", "unsigned long", "unsigned long long"); - { - 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(\"%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" - " &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"); + TEST_SCANF_HHU("bool"); + TEST_SCANF_HHU("char"); + TEST_SCANF_HHU("signed char"); + TEST_SCANF_HHU("unsigned char"); + TEST_SCANF_HHU("short"); + TEST_SCANF_HHU("signed short"); + TEST_SCANF_HHU("unsigned short"); + TEST_SCANF_HHU("int"); + TEST_SCANF_HHU("signed int"); + TEST_SCANF_HHU("long"); + TEST_SCANF_HHU("signed long"); + TEST_SCANF_HHU("unsigned long"); + TEST_SCANF_HHU("long long"); + TEST_SCANF_HHU("signed long long"); + TEST_SCANF_HHU("unsigned long long"); + TEST_SCANF_HHU("float"); + TEST_SCANF_HHU("double"); + TEST_SCANF_HHU("long double"); + TEST_SCANF_HHU_AKA("size_t", "unsigned long", "unsigned long long"); + TEST_SCANF_HHU_AKA("ssize_t", "long", "long long"); + TEST_SCANF_HHU_AKA("ptrdiff_t", "long", "long long"); + TEST_SCANF_HHU_AKA("intmax_t", "long", "long long"); + TEST_SCANF_HHU_AKA("uintmax_t", "unsigned long", "unsigned long long"); + TEST_SCANF_HHU("void *"); + TEST_SCANF_HHU_AKA("std::size_t", "unsigned long", "unsigned long long"); + TEST_SCANF_HHU_AKA("std::ssize_t", "long", "long long"); + TEST_SCANF_HHU_AKA("std::ptrdiff_t", "long", "long long"); + TEST_SCANF_HHU_AKA("std::intptr_t", "long", "long long"); + TEST_SCANF_HHU_AKA("std::uintptr_t", "unsigned long", "unsigned long long"); - 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()); - } + TEST_SCANF_Lu("bool"); + TEST_SCANF_Lu("char"); + TEST_SCANF_Lu("signed char"); + TEST_SCANF_Lu("unsigned char"); + TEST_SCANF_Lu("short"); + TEST_SCANF_Lu("signed short"); + TEST_SCANF_Lu("unsigned short"); + 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"); - { - 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(\"%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" - " &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"); + TEST_SCANF_JU("bool"); + TEST_SCANF_JU("char"); + TEST_SCANF_JU("signed char"); + TEST_SCANF_JU("unsigned char"); + TEST_SCANF_JU("short"); + TEST_SCANF_JU("signed short"); + TEST_SCANF_JU("unsigned short"); + TEST_SCANF_JU("int"); + TEST_SCANF_JU("signed int"); + TEST_SCANF_JU("long"); + TEST_SCANF_JU("signed long"); + TEST_SCANF_JU("unsigned long"); + TEST_SCANF_JU("long long"); + TEST_SCANF_JU("signed long long"); + TEST_SCANF_JU("unsigned long long"); + TEST_SCANF_JU("float"); + TEST_SCANF_JU("double"); + TEST_SCANF_JU("long double"); + TEST_SCANF_JU_AKA("size_t", "unsigned long", "unsigned long long"); + TEST_SCANF_JU_AKA("ssize_t", "long", "long long"); + TEST_SCANF_JU_AKA("ptrdiff_t", "long", "long long"); + TEST_SCANF_JU_AKA("intmax_t", "long", "long long"); + TEST_SCANF_JU_AKA("uintmax_t", "unsigned long", "unsigned long long"); + TEST_SCANF_JU("void *"); + TEST_SCANF_JU_AKA("std::size_t", "unsigned long", "unsigned long long"); + TEST_SCANF_JU_AKA("std::ssize_t", "long", "long long"); + TEST_SCANF_JU_AKA("std::ptrdiff_t", "long", "long long"); + TEST_SCANF_JU_AKA("std::intptr_t", "long", "long long"); + TEST_SCANF_JU_AKA("std::uintptr_t", "unsigned long", "unsigned long long"); - 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()); - } + TEST_SCANF_ZU("bool"); + TEST_SCANF_ZU("char"); + TEST_SCANF_ZU("signed char"); + TEST_SCANF_ZU("unsigned char"); + TEST_SCANF_ZU("short"); + TEST_SCANF_ZU("signed short"); + TEST_SCANF_ZU("unsigned short"); + 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"); - { - 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(\"%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" - " &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()); + TEST_SCANF_TU("bool"); + TEST_SCANF_TU("char"); + TEST_SCANF_TU("signed char"); + TEST_SCANF_TU("unsigned char"); + TEST_SCANF_TU("short"); + TEST_SCANF_TU("signed short"); + TEST_SCANF_TU("unsigned short"); + TEST_SCANF_TU("int"); + TEST_SCANF_TU("signed int"); + TEST_SCANF_TU("long"); + TEST_SCANF_TU("signed long"); + TEST_SCANF_TU("unsigned long"); + TEST_SCANF_TU("long long"); + TEST_SCANF_TU("signed long long"); + TEST_SCANF_TU("unsigned long long"); + TEST_SCANF_TU("float"); + TEST_SCANF_TU("double"); + TEST_SCANF_TU("long double"); + TEST_SCANF_TU_AKA("size_t", "unsigned long", "unsigned long long"); + TEST_SCANF_TU_AKA("ssize_t", "long", "long long"); + TEST_SCANF_TU_AKA("ptrdiff_t", "long", "long long"); + TEST_SCANF_TU_AKA("intmax_t", "long", "long long"); + TEST_SCANF_TU_AKA("uintmax_t", "unsigned long", "unsigned long long"); + TEST_SCANF_TU("void *"); + TEST_SCANF_TU_AKA("std::size_t", "unsigned long", "unsigned long long"); + TEST_SCANF_TU_AKA("std::ssize_t", "long", "long long"); + TEST_SCANF_TU_AKA("std::ptrdiff_t", "long", "long long"); + TEST_SCANF_TU_AKA("std::intptr_t", "long", "long long"); + TEST_SCANF_TU_AKA("std::uintptr_t", "unsigned long", "unsigned long long"); check("void foo() {\n" " bool b;\n"