diff options
Diffstat (limited to 'gcc/tree-chkp.c')
-rw-r--r-- | gcc/tree-chkp.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index 3fba12c2ae4..4ca2d34607c 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -1853,7 +1853,9 @@ chkp_add_bounds_to_call_stmt (gimple_stmt_iterator *gsi) /* If function decl is available then use it for formal arguments list. Otherwise use function type. */ - if (fndecl && DECL_ARGUMENTS (fndecl)) + if (fndecl + && DECL_ARGUMENTS (fndecl) + && gimple_call_fntype (call) == TREE_TYPE (fndecl)) first_formal_arg = DECL_ARGUMENTS (fndecl); else { @@ -1929,7 +1931,16 @@ chkp_add_bounds_to_call_stmt (gimple_stmt_iterator *gsi) { tree new_decl = chkp_maybe_create_clone (fndecl)->decl; gimple_call_set_fndecl (new_call, new_decl); - gimple_call_set_fntype (new_call, TREE_TYPE (new_decl)); + /* In case of a type cast we should modify used function + type instead of using type of new fndecl. */ + if (gimple_call_fntype (call) != TREE_TYPE (fndecl)) + { + tree type = gimple_call_fntype (call); + type = chkp_copy_function_type_adding_bounds (type); + gimple_call_set_fntype (new_call, type); + } + else + gimple_call_set_fntype (new_call, TREE_TYPE (new_decl)); } /* For indirect call we should fix function pointer type if pass some bounds. */ @@ -3646,6 +3657,7 @@ chkp_find_bounds_1 (tree ptr, tree ptr_src, gimple_stmt_iterator *iter) break; case ADDR_EXPR: + case WITH_SIZE_EXPR: bounds = chkp_make_addressed_object_bounds (TREE_OPERAND (ptr_src, 0), iter); break; |