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
015e637b4b. 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ö <martin@martin.st>
We should prefer using a macro which doesn't declare functions
as static inline in C++ mode.
This macro was added in bc6a874889,
without an explanation of why it was added.
Signed-off-by: Martin Storsjö <martin@martin.st>
This prevents bogus warnings or build aborts (-Werror) if Windows
includes are used on Cygwin.
Signed-off-by: Christian Franke <christian.franke@t-online.de>
Signed-off-by: LIU Hao <lh_mouse@126.com>
Check for support of __builtin_dynamic_object_size() and
__builtin_va_arg_pack() with __has_builtin().
Signed-off-by: Christian Franke <christian.franke@t-online.de>
Signed-off-by: Martin Storsjö <martin@martin.st>
If specified, __builtin_dynamic_object_size() is used instead of
__builtin_object_size() if supported (GCC 12.0 or later).
This enables buffer overflow checks if the buffer size is non-const
but known during runtime.
Signed-off-by: Christian Franke <christian.franke@t-online.de>
Signed-off-by: LIU Hao <lh_mouse@126.com>
There's no problem in using the "artificial" attribute with Clang,
at least as of Clang 10.0.
Clarify why Clang is excluded for __MINGW_FORTIFY_VA_ARG.
Signed-off-by: Martin Storsjö <martin@martin.st>
While clang does match MSVC with regards to aggregate returns, when
run in MSVC mode, it matches GCC when run in mingw mode - and the
same behaviour extends to arm/aarch64 too.
Thus, this workaround needs to be enabled on all architectures,
not only on x86.
Signed-off-by: Martin Storsjö <martin@martin.st>
This enables the old behavior when `-funsigned-char` is specified.
The `selectany` attribute is assumed to be supported since GCC 4.2, and
probably by Clang as well.
This test program should print 127 when `char` is signed and 255 when it
is unsigned:
#include <stdio.h>
#include <locale.h>
int main(void)
{
struct lconv* lc = localeconv();
printf("frac_digits = %d\n", lc->frac_digits);
}
Reference: https://sourceforge.net/p/mingw-w64/mailman/message/37300502/
Reference: https://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Variable-Attributes.html
Signed-off-by: Liu Hao <lh_mouse@126.com>
Add parameter 'maxtype' to __mingw_bos*() macros. Allows to force usage
of __builtin_object_size(p, 0) even if _FORTIFY_SOURCE=2 is set.
Signed-off-by: Liu Hao <lh_mouse@126.com>
_FORTIFY_VA_ARG=0 disables inline functions with __builtin_va_arg_pack().
This allows _FORTIFY_SOURCE also in the rare case that the address of a
s*printf() function is used.
Signed-off-by: Christian Franke <christian.franke@t-online.de>
Signed-off-by: Liu Hao <lh_mouse@126.com>
GCC may report an error if the address of an inline function with
_buildin_va_arg_pack() is used. Keep the old inline functions if
_FORTIFY_SOURCE is disabled.
Signed-off-by: Christian Franke <christian.franke@t-online.de>
Signed-off-by: Martin Storsjö <martin@martin.st>
Always use '__gnu_inline__' with 'extern inline __always_inline__'.
This avoids generation of bogus non-inline functions if function
address is used.
Don't use '__gnu_inline__' with 'static inline' or C++ 'inline'.
This avoids undefined symbols if function address is used.
Signed-off-by: Christian Franke <christian.franke@t-online.de>
Signed-off-by: Martin Storsjö <martin@martin.st>
In C++ mode, __mingw_ovr is a plain "inline" without "static".
Clang emits a standalone (non-comdat) copy of functions in C++ for
the combination of non-static inline (without extern) and __gnu_inline__,
leading to multiple definitions of symbols.
Signed-off-by: Martin Storsjö <martin@martin.st>
setjmp.h only checks for _ARM64_, not for __aarch64__, but so far,
only winnt.h defined this. Since _mingw_mac.h also defines some of
the defines that winnt.h does (like _ARM_), do the same for _ARM64_.
Signed-off-by: Martin Storsjö <martin@martin.st>
This intercepts the function calls that the mingw CRT startup and
other libmingwex helpers expect to use, that no longer is available on
ucrtbase.dll.
This allows using the same CRT startup object files and libmingwex both
with the normal msvcrt.dll and with ucrtbase.dll, instead of having to
rebuild them depending on which target is to be used.
Adjust the headers to make some of the inline functions static in C++
builds as well; this fixes issues with duplicate symbols where the
non-static inline function (in C++ builds) would conflict with the
CRT compat fallbacks.
Signed-off-by: Martin Storsjö <martin@martin.st>
Do further optimization for math-inlines to avoid for long double types unnecessary load/store via x87 instructions.
git-svn-id: svn+ssh://svn.code.sf.net/p/mingw-w64/code/trunk@6304 4407c894-4637-0410-b4f5-ada5f102cad1
new features / bug-fixes. By this we can provide users a chance to detect
proper runtime-version in headers.
git-svn-id: svn+ssh://svn.code.sf.net/p/mingw-w64/code/trunk@5522 4407c894-4637-0410-b4f5-ada5f102cad1
Also replace 'This file is a part of' by 'This file is part of' for consistency
git-svn-id: svn+ssh://svn.code.sf.net/p/mingw-w64/code/trunk@5147 4407c894-4637-0410-b4f5-ada5f102cad1