Skip to content

Commit 99efff2

Browse files
committed
C++: Fix a FP in cpp/wrong-number-format-arguments caused by extraction error
1 parent 08859be commit 99efff2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

cpp/ql/src/Likely Bugs/Format/WrongNumberOfFormatArguments.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ where
4444
) and
4545
// A typical problem is that string literals are concatenated, but if one of the string
4646
// literals is an undefined macro, then this just leads to a syntax error.
47-
not exists(SyntaxError e | e.affects(fl))
47+
not exists(SyntaxError e | e.affects(fl)) and
48+
not ffc.getArgument(_) instanceof ErrorExpr
4849
select ffc,
4950
"Format for " + ffcName + " expects " + expected.toString() + " arguments but given " +
5051
given.toString()

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
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 |
98
| test.c:9:2:9:7 | call to printf | Format for printf expects 1 arguments but given 0 |
109
| test.c:12:2:12:7 | call to printf | Format for printf expects 2 arguments but given 1 |
1110
| test.c:15:2:15:7 | call to printf | Format for printf expects 3 arguments but given 2 |

0 commit comments

Comments
 (0)