================
@@ -255,3 +255,27 @@ void dontCrashForInvalidFormatString() {
snprintf((char*)0, 0, "%");
snprintf((char*)0, 0, "\0");
}
+
+
+// Also warn about unsafe printf/scanf-like functions:
+void myprintf(const char *F, ...) __attribute__((__format__ (__printf__, 1,
2)));
----------------
ziqingluo-90 wrote:
It will be a compilation error when the format string does not come before the
first argument. There are existing tests for such cases:
https://github.com/llvm/llvm-project/blob/38cdadd9c74509be636e41778043e4cd270be04b/clang/test/Sema/attr-format.c#L1C1-L14C1
I will sure add the case where the format string is not the first argument.
https://github.com/llvm/llvm-project/pull/173096
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits