diff options
author | Florian Weimer <fweimer@redhat.com> | 2025-05-02 11:39:29 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2025-05-02 11:39:29 +0200 |
commit | 02fa088f5b61fb5ddfff9e2dc0c0404450e7c6a4 (patch) | |
tree | 1cd4118e1f727a9915159aa24d9766b3e7999e86 /gcc | |
parent | cdfa963cfc6849ff3ceb911f293201882aeef22e (diff) | |
download | gcc-02fa088f5b61fb5ddfff9e2dc0c0404450e7c6a4.zip gcc-02fa088f5b61fb5ddfff9e2dc0c0404450e7c6a4.tar.gz gcc-02fa088f5b61fb5ddfff9e2dc0c0404450e7c6a4.tar.bz2 |
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c/c-typeck.cc | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wdeprecated-non-prototype-6.c | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index c7a13bf..05fb129 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -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 index 0000000..08f2995 --- /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); +} |