Skip to content

Commit 28c5187

Browse files
committed
C++: Remove FPs in cpp/wrong-type-format-argument when string type is an error
1 parent 1942402 commit 28c5187

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ where
171171
not arg.isAffectedByMacro() and
172172
not arg.isFromUninstantiatedTemplate(_) and
173173
not actual.getUnspecifiedType() instanceof ErroneousType and
174+
not (
175+
expected instanceof PointerType and
176+
actual.getUnspecifiedType().(PointerType).getBaseType() instanceof ErroneousType
177+
) and
174178
not arg.(Call).mayBeFromImplicitlyDeclaredFunction()
175179
select arg,
176180
"This format specifier for type '" + expected.getName() + "' does not match the argument type '" +
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
| tests.c:7:18:7:18 | 1 | This format specifier for type 'char *' does not match the argument type 'int'. |
2-
| tests.c:11:18:11:20 | str | This format specifier for type 'char *' does not match the argument type '<error-type> *'. |

0 commit comments

Comments
 (0)