Skip to content

Commit 147d699

Browse files
committed
C++: Add another test case
1 parent 99efff2 commit 147d699

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
| macros.cpp:14:2:14:37 | call to printf | Format for printf (in a macro expansion) expects 4 arguments but given 3 |
66
| macros.cpp:21:2:21:36 | call to printf | Format for printf (in a macro expansion) expects 4 arguments but given 3 |
77
| macros.cpp:32:2:32:25 | call to printf | Format for printf (in a macro expansion) expects 1 arguments but given 0 |
8+
| syntax_errors.c:15:5:15:10 | call to printf | Format for printf expects 2 arguments but given 0 |
89
| test.c:9:2:9:7 | call to printf | Format for printf expects 1 arguments but given 0 |
910
| test.c:12:2:12:7 | call to printf | Format for printf expects 2 arguments but given 1 |
1011
| test.c:15:2:15:7 | call to printf | Format for printf expects 3 arguments but given 2 |

cpp/ql/test/query-tests/Likely Bugs/Format/WrongNumberOfFormatArguments/syntax_errors.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@
33
extern int printf(const char *fmt, ...);
44

55
void test_syntax_error() {
6+
// GOOD
67
printf("Error code %d: " UNDEFINED_MACRO, 0, "");
78

9+
// GOOD
810
printf("%d%d",
911
(UNDEFINED_MACRO)1,
1012
(UNDEFINED_MACRO)2);
13+
14+
// GOOD [FALSE POSITIVE]
15+
printf("%d%d"
16+
UNDEFINED_MACRO,
17+
1, 2);
1118
}

0 commit comments

Comments
 (0)