]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c: Fix crash in c-typeck.cc convert_arguments with indirect calls
authorFlorian Weimer <fweimer@redhat.com>
Fri, 2 May 2025 09:39:29 +0000 (11:39 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Fri, 2 May 2025 09:39:29 +0000 (11:39 +0200)
gcc/c/

PR c/120055
* c-typeck.cc (convert_arguments): Check if fundecl is null
before checking for builtin function declaration.

gcc/testsuite/

* gcc.dg/Wdeprecated-non-prototype-6.c: New test.

gcc/c/c-typeck.cc
gcc/testsuite/gcc.dg/Wdeprecated-non-prototype-6.c [new file with mode: 0644]

index c7a13bf2b2f4235a62bd1dd220288998a80eabd1..05fb129ada8d6be92a2e1917f0fdea2e0e3f7f3c 100644 (file)
@@ -4337,7 +4337,7 @@ convert_arguments (location_t loc, vec<location_t> arg_loc, tree fntype,
        }
 
       if (!typetail && parmnum == 0 && !TYPE_NO_NAMED_ARGS_STDARG_P (fntype)
-         && !fndecl_built_in_p (fundecl))
+         && !(fundecl && fndecl_built_in_p (fundecl)))
        {
          auto_diagnostic_group d;
          bool warned;
diff --git a/gcc/testsuite/gcc.dg/Wdeprecated-non-prototype-6.c b/gcc/testsuite/gcc.dg/Wdeprecated-non-prototype-6.c
new file mode 100644 (file)
index 0000000..08f2995
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu17 -Wdeprecated-non-prototype" } */
+
+void (*f1) ();
+void (*f2) ();
+void (*f3) (...);
+
+void
+g ()
+{
+  f1 ();
+  f2 (1); /* { dg-warning "does not allow arguments for function" } */
+  f3 (1);
+}