Skip to content

Commit 1ee28fa

Browse files
committed
CPP: Add a test cases that uses restrict.
1 parent a749b5b commit 1ee28fa

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Linux_signed_chars/WrongTypeFormatArguments.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
| format.h:16:59:16:61 | str | This argument should be of type 'int' but is of type 'char *' |
22
| format.h:16:64:16:64 | i | This argument should be of type 'double' but is of type 'int' |
33
| format.h:16:67:16:67 | d | This argument should be of type 'char *' but is of type 'double' |
4+
| linux_c.c:11:15:11:18 | str3 | This argument should be of type 'char *' but is of type 'short *' |
45
| pri_macros.h:15:35:15:40 | my_u64 | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
56
| printf1.h:12:27:12:27 | i | This argument should be of type 'double' but is of type 'int' |
67
| printf1.h:18:18:18:18 | i | This argument should be of type 'void *' but is of type 'int' |
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/** standard printf functions */
2+
3+
int printf(const char *format, ...);
4+
5+
/** test program */
6+
7+
void restrict_cases(char * restrict str1, const char * restrict str2, short * restrict str3)
8+
{
9+
printf("%s", str1); // GOOD
10+
printf("%s", str2); // GOOD
11+
printf("%s", str3); // BAD
12+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
semmle-extractor-options: --edg --signed_chars
1+
semmle-extractor-options: --clang --edg --signed_chars

0 commit comments

Comments
 (0)