Merge pull request #1979 from nickrolfe/wrong_type_uninstantiated

C++: ignore uninstantiated templates in WrongTypeFormatArguments.ql
This commit is contained in:
Robert Marsh
2019-09-19 14:51:45 -07:00
committed by GitHub
3 changed files with 23 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
| format.h:16:59:16:61 | str | This argument should be of type 'int' but is of type 'char *' |
| format.h:16:64:16:64 | i | This argument should be of type 'double' but is of type 'int' |
| format.h:16:67:16:67 | d | This argument should be of type 'char *' but is of type 'double' |
| linux.cpp:15:24:15:41 | call to get_template_value | This argument should be of type 'int' but is of type 'long' |
| linux_c.c:11:15:11:18 | str3 | This argument should be of type 'char *' but is of type 'short *' |
| pri_macros.h:15:35:15:40 | my_u64 | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
| printf1.h:12:27:12:27 | i | This argument should be of type 'double' but is of type 'int' |

View File

@@ -2,3 +2,23 @@ typedef unsigned long size_t;
typedef long ssize_t;
#include "common.h"
template <typename T>
struct S {
int get_int();
T get_template_value();
};
template <typename U>
void template_func_calling_printf(S<U> &obj) {
::printf("%d\n", obj.get_int());
::printf("%d\n", obj.get_template_value());
}
void instantiate() {
S<int> s_int;
S<long> s_long;
template_func_calling_printf(s_int); // ok
template_func_calling_printf(s_long); // not ok (long -> int)
}