C++: Add regression test

This commit is contained in:
Calum Grant
2024-09-26 08:57:08 +01:00
parent 297d32180c
commit 6a0212ea44
3 changed files with 14 additions and 0 deletions

View File

@@ -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 |

View File

@@ -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))) {}

View File

@@ -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);