]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c: Suppress -Wdeprecated-non-prototype warnings for builtins
authorFlorian Weimer <fweimer@redhat.com>
Thu, 1 May 2025 17:06:45 +0000 (19:06 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Thu, 1 May 2025 17:06:45 +0000 (19:06 +0200)
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
gcc/testsuite/gcc.dg/Wdeprecated-non-prototype-5.c [new file with mode: 0644]

index d94ecb5b743a54793ee3496f8719a2c3adebde70..c7a13bf2b2f4235a62bd1dd220288998a80eabd1 100644 (file)
@@ -4336,7 +4336,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))
        {
          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 (file)
index 0000000..b231a74
--- /dev/null
@@ -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);
+}