Clang doesn't support the ms_printf/scanf and gnu_printf/scanf format attributes, only plain "printf" and "scanf".
We already expand e.g. __MINGW_PRINTF_FORMAT (which differs depending on __USE_MINGW_ANSI_STDIO) into plain "printf" for Clang, since 015e637b4b24d9915162ab877ed539ad0e657951. However, a number of functions explicitly declared either gnu or ms style formats, which caused these functions to not get any format string diagnostics. This fixes https://github.com/llvm/llvm-project/issues/68995, which reported that no warnings are produced for mismatched printf/scanf format strings, when compiling with Clang, with a toolchain targeting msvcrt (i.e. in practice using __USE_MINGW_ANSI_STDIO enabled). Signed-off-by: Martin Storsjö <mar...@martin.st> --- mingw-w64-headers/crt/_mingw_mac.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mingw-w64-headers/crt/_mingw_mac.h b/mingw-w64-headers/crt/_mingw_mac.h index 9de143e5d..6c133d00e 100644 --- a/mingw-w64-headers/crt/_mingw_mac.h +++ b/mingw-w64-headers/crt/_mingw_mac.h @@ -267,6 +267,19 @@ # define __MINGW_ATTRIB_DEPRECATED_SEC_WARN #endif +#ifdef __clang__ +#define __MINGW_MS_PRINTF(__format,__args) \ + __attribute__((__format__(printf, __format,__args))) + +#define __MINGW_MS_SCANF(__format,__args) \ + __attribute__((__format__(scanf, __format,__args))) + +#define __MINGW_GNU_PRINTF(__format,__args) \ + __attribute__((__format__(printf,__format,__args))) + +#define __MINGW_GNU_SCANF(__format,__args) \ + __attribute__((__format__(scanf, __format,__args))) +#else #define __MINGW_MS_PRINTF(__format,__args) \ __attribute__((__format__(ms_printf, __format,__args))) @@ -278,6 +291,7 @@ #define __MINGW_GNU_SCANF(__format,__args) \ __attribute__((__format__(gnu_scanf, __format,__args))) +#endif /* !__clang__ */ #undef __mingw_ovr -- 2.34.1 _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public