[PATCH] c: Suppress -Wdeprecated-non-prototype warnings for builtins
Richard Sandiford
richard.sandiford@arm.com
Thu May 1 20:59:08 GMT 2025
Florian Weimer <fweimer@redhat.com> writes:
> Builtins defined with BT_FN_INT_VAR etc. show as functions without
> a prototype and trigger the warning.
>
> gcc/c/
>
> PR c/119950
> * c-typeck.cc (convert_arguments): Check for built-in
> function declaration before warning.
>
> gcc/testsuite/
>
> * gcc.dg/Wdeprecated-non-prototype-5.c: New test.
>
> ---
> gcc/c/c-typeck.cc | 3 ++-
> gcc/testsuite/gcc.dg/Wdeprecated-non-prototype-5.c | 14 ++++++++++++++
> 2 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
> index 55d896e02df..f8d1f711513 100644
> --- a/gcc/c/c-typeck.cc
> +++ b/gcc/c/c-typeck.cc
> @@ -4342,7 +4342,8 @@ convert_arguments (location_t loc, vec<location_t> arg_loc, tree fntype,
> builtin_typetail = NULL_TREE;
> }
>
> - if (!typetail && parmnum == 0 && !TYPE_NO_NAMED_ARGS_STDARG_P (fntype))
> + if (!typetail && parmnum == 0 && !TYPE_NO_NAMED_ARGS_STDARG_P (fntype)
> + && !fndecl_built_in_p (fundecl))
This is causing gcc.c-compile/callind.c and others to segfault on
aarch64, since fundecl can be null for indirect calls.
Thanks,
Richard
> {
> auto_diagnostic_group d;
> bool warned;
> diff --git a/gcc/testsuite/gcc.dg/Wdeprecated-non-prototype-5.c b/gcc/testsuite/gcc.dg/Wdeprecated-non-prototype-5.c
> new file mode 100644
> index 00000000000..b231a74cebe
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/Wdeprecated-non-prototype-5.c
> @@ -0,0 +1,14 @@
> +/* { dg-do compile } */
> +/* { dg-options "-Wdeprecated-non-prototype" } */
> +
> +static inline
> +int f (int x)
> +{
> + return __builtin_constant_p (x);
> +}
> +
> +static inline
> +int g (double x)
> +{
> + return __builtin_isfinite (x);
> +}
>
> base-commit: 0035613389a939043d654aea7a76faae95f69422
More information about the Gcc-patches
mailing list