Skip to content

Commit 08859be

Browse files
committed
C++: Test case for cpp/wrong-number-format-arguments
1 parent cc4382c commit 08859be

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
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:8:5:8:10 | call to printf | Format for printf expects 2 arguments but given 1 |
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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@
33
extern int printf(const char *fmt, ...);
44

55
void test_syntax_error() {
6-
printf("Error code %d: " FMT_MSG, 0, "");
6+
printf("Error code %d: " UNDEFINED_MACRO, 0, "");
7+
8+
printf("%d%d",
9+
(UNDEFINED_MACRO)1,
10+
(UNDEFINED_MACRO)2);
711
}

0 commit comments

Comments
 (0)