diff options
author | Jakub Jelinek <jakub@redhat.com> | 2023-05-10 13:20:39 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2023-05-10 13:20:39 +0200 |
commit | 395a75593ef87a68a04111bb08243b5d9a811f45 (patch) | |
tree | 883ed48e02f0eaa8c4cce3d760ca16b44ae06cec | |
parent | 5a7dda68000dcbe6c54735313521228812b10893 (diff) | |
download | gcc-395a75593ef87a68a04111bb08243b5d9a811f45.zip gcc-395a75593ef87a68a04111bb08243b5d9a811f45.tar.gz gcc-395a75593ef87a68a04111bb08243b5d9a811f45.tar.bz2 |
ipa-prop: Fix ipa_get_callee_param_type for calls with argument type mismatches
The PR contains a testcase where the Fortran FE creates FUNCTION_TYPE
which doesn't really match the passed in arguments (FUNCTION_TYPE has
5 arguments, call has 6). Now, I think that is a Fortran FE bug that
should be fixed there, but I think with function pointers one can
create something similar (of course invalid) in C/C++ too,so IMHO IPA
should be also more careful.
The ipa_get_callee_param_type function can return NULL if something goes
wrong and it does e.g. if asked for 7th argument type on a function
with just 5 arguments and similar. But, if a function isn't varargs,
when asked for 6th argument type on a function with just 5 arguments
it actually returns void_type_node because the argument list is in that
case terminated with void_list_node.
The following patch makes sure we don't treat void_list_node as something
holding another argument.
2023-05-10 Jakub Jelinek <jakub@redhat.com>
PR fortran/109788
* ipa-prop.cc (ipa_get_callee_param_type): Don't return TREE_VALUE (t)
if t is void_list_node.
-rw-r--r-- | gcc/ipa-prop.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc index 0f3cb3d..d7d70e5 100644 --- a/gcc/ipa-prop.cc +++ b/gcc/ipa-prop.cc @@ -2147,7 +2147,7 @@ ipa_get_callee_param_type (struct cgraph_edge *e, int i) break; t = TREE_CHAIN (t); } - if (t) + if (t && t != void_list_node) return TREE_VALUE (t); if (!e->callee) return NULL; |