mirror of
https://github.com/github/codeql.git
synced 2026-04-29 10:45:15 +02:00
CPP: Improve WrongTypeFormatArguments logic when there is more than one possible expected argument type.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
| tests.cpp:18:15:18:22 | Hello | This argument should be of type 'char *' but is of type 'char16_t *' |
|
||||
| tests.cpp:19:15:19:22 | Hello | This argument should be of type 'char *' but is of type 'wchar_t *' |
|
||||
| tests.cpp:21:15:21:21 | Hello | This argument should be of type 'char16_t *' but is of type 'char *' |
|
||||
| tests.cpp:21:15:21:21 | Hello | This argument should be of type 'wchar_t *' but is of type 'char *' |
|
||||
| tests.cpp:26:17:26:24 | Hello | This argument should be of type 'char *' but is of type 'char16_t *' |
|
||||
| tests.cpp:27:17:27:24 | Hello | This argument should be of type 'char *' but is of type 'wchar_t *' |
|
||||
| tests.cpp:29:17:29:23 | Hello | This argument should be of type 'wchar_t *' but is of type 'char *' |
|
||||
|
||||
@@ -18,7 +18,7 @@ void tests() {
|
||||
printf("%s", u"Hello"); // BAD: expecting char
|
||||
printf("%s", L"Hello"); // BAD: expecting char
|
||||
|
||||
printf("%S", "Hello"); // BAD: expecting wchar_t or char16_t [NOT DETECTED]
|
||||
printf("%S", "Hello"); // BAD: expecting wchar_t or char16_t
|
||||
printf("%S", u"Hello"); // GOOD
|
||||
printf("%S", L"Hello"); // GOOD
|
||||
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
| tests_32.cpp:14:16:14:23 | void_ptr | This argument should be of type 'long' but is of type 'void *' |
|
||||
| tests_32.cpp:15:15:15:15 | l | This argument should be of type 'void *' but is of type 'long' |
|
||||
| tests_64.cpp:14:16:14:23 | void_ptr | This argument should be of type 'long' but is of type 'void *' |
|
||||
| tests_64.cpp:15:15:15:15 | l | This argument should be of type 'void *' but is of type 'long' |
|
||||
|
||||
@@ -12,6 +12,6 @@ void test_32()
|
||||
|
||||
printf("%li", l); // GOOD
|
||||
printf("%li", void_ptr); // BAD
|
||||
printf("%p", l); // BAD [NOT DETECTED]
|
||||
printf("%p", l); // BAD
|
||||
printf("%p", void_ptr); // GOOD
|
||||
}
|
||||
|
||||
@@ -12,6 +12,6 @@ void test_64()
|
||||
|
||||
printf("%li", l); // GOOD
|
||||
printf("%li", void_ptr); // BAD
|
||||
printf("%p", l); // BAD [NOT DETECTED]
|
||||
printf("%p", l); // BAD
|
||||
printf("%p", void_ptr); // GOOD
|
||||
}
|
||||
|
||||
@@ -32,3 +32,4 @@
|
||||
| real_world.h:63:22:63:24 | & ... | This argument should be of type 'short *' but is of type 'unsigned int *' |
|
||||
| real_world.h:64:22:64:24 | & ... | This argument should be of type 'short *' but is of type 'signed int *' |
|
||||
| wide_string.h:25:18:25:20 | c | This argument should be of type 'char' but is of type 'char *' |
|
||||
| wide_string.h:29:19:29:22 | c | This argument should be of type 'wchar_t' but is of type 'unsigned short *' |
|
||||
|
||||
@@ -26,5 +26,5 @@ void test_wchar4(char c, const char cc, wchar_t wc, const wchar_t wcc) {
|
||||
printf("%wc", wc); // GOOD
|
||||
printf("%wc", wcc); // GOOD
|
||||
printf("%wc", L'c'); // GOOD
|
||||
printf("%wc", L"c"); // BAD [NOT DETECTED]
|
||||
printf("%wc", L"c"); // BAD
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user