From: Florian Weimer Date: Fri, 2 May 2025 09:39:29 +0000 (+0200) Subject: c: Fix crash in c-typeck.cc convert_arguments with indirect calls X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5768bc24ca731943755ab937abc7617950e80037;p=thirdparty%2Fgcc.git c: Fix crash in c-typeck.cc convert_arguments with indirect calls 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. (cherry picked from commit 02fa088f5b61fb5ddfff9e2dc0c0404450e7c6a4) --- diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 9f1a94f98ad..b007c8ffe76 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -4343,7 +4343,7 @@ convert_arguments (location_t loc, vec 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 index 00000000000..08f2995d5b2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wdeprecated-non-prototype-6.c @@ -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); +}