mirror of
https://github.com/github/codeql.git
synced 2026-04-20 22:44:52 +02:00
C++: Add regression test
This commit is contained in:
@@ -10,3 +10,6 @@
|
||||
| test.c:15:2:15:7 | call to printf | Format for printf expects 3 arguments but given 2 |
|
||||
| test.c:19:2:19:7 | call to printf | Format for printf expects 2 arguments but given 1 |
|
||||
| test.c:29:3:29:8 | call to printf | Format for printf expects 2 arguments but given 1 |
|
||||
| test.c:51:2:51:10 | call to my_logger | Format for my_logger expects 6 arguments but given 1 |
|
||||
| test.c:52:2:52:10 | call to my_logger | Format for my_logger expects 3 arguments but given 0 |
|
||||
| test.c:53:2:53:10 | call to my_logger | Format for my_logger expects 3 arguments but given 0 |
|
||||
|
||||
@@ -44,3 +44,6 @@ void test_custom_printf2()
|
||||
printf("", "%i %i", 100, 200); // GOOD
|
||||
printf("%i %i", "" ); // GOOD
|
||||
}
|
||||
|
||||
extern "C" void my_logger(int param, char *fmt, ...) __attribute__((format(printf, 2, 3))) {}
|
||||
|
||||
|
||||
@@ -46,4 +46,12 @@ void test(int i, const char *str)
|
||||
printf("%Y", 1, 2); // GOOD (unknown format character, this might be correct)
|
||||
printf("%1.1Y", 1, 2); // GOOD (unknown format character, this might be correct)
|
||||
printf("%*.*Y", 1, 2); // GOOD (unknown format character, this might be correct)
|
||||
|
||||
// Implicit logger function declaration
|
||||
my_logger(0, "%i %i %i %i %i %i\n", 1, 2, 3, 4, 5, 6); // GOOD (FP)
|
||||
my_logger(0, "%i %i %i\n", 1, 2, 3); // GOOD (FP)
|
||||
my_logger(0, "%i %i %i\n", 1, 2); // BAD (too few format arguments)
|
||||
}
|
||||
|
||||
// A spurious definition of my_logger
|
||||
extern void my_logger(int param, char *fmt, int, int, int, int, int);
|
||||
|
||||
Reference in New Issue
Block a user