PR middle-end/97373 - missing warning on sprintf into allocated destination
authorMartin Sebor <msebor@redhat.com>
Tue, 1 Dec 2020 20:38:08 +0000 (13:38 -0700)
committerMartin Sebor <msebor@redhat.com>
Tue, 1 Dec 2020 20:39:46 +0000 (13:39 -0700)
commitd02c41dd414dcc65a08bc82f312f7808b5d90028
tree1e37ab650d96cc4b1bf719bc64cda60c5b6b8342
parentb3147c02dc772ad77eb7e1d5d6e14a8f222d1e65
PR middle-end/97373 - missing warning on sprintf into allocated destination

gcc/ChangeLog:

PR middle-end/97373
* builtins.c (compute_objsize): Rename...
(compute_objsize_r): to this.  Change order and types of arguments.
Use new argument.  Adjust calls to self.
(access_ref::get_ref): New member function.
(pointer_query::pointer_query): New member function.
(pointer_query::get_ref): Same.
(pointer_query::put_ref): Same.
(handle_min_max_size): Change order and types of arguments.
(maybe_emit_free_warning): Add a test.
* builtins.h (class pointer_query): New class.
(compute_objsize): Declare an overload.
* gimple-ssa-sprintf.c (get_destination_size): Add argument.
(handle_printf_call): Change argument type.
* tree-ssa-strlen.c (adjust_last_stmt): Add an argument and use it.
(maybe_warn_overflow): Same.
(handle_builtin_strcpy): Same.
(maybe_diag_stxncpy_trunc): Same.
(handle_builtin_memcpy): Change argument type.  Adjust calls.
(handle_builtin_strcat): Same.
(handle_builtin_memset): Same.
(handle_store): Same.
(strlen_check_and_optimize_call): Same.
(check_and_optimize_stmt): Same.
(strlen_dom_walker): Add new data members.
(strlen_dom_walker::before_dom_children): Use new member.
(printf_strlen_execute): Dump cache performance counters.  Remove
objsize pass cleanup.
* tree-ssa-strlen.h (maybe_diag_stxncpy_trunc): Add argument.
(handle_printf_call): Change argument type.

gcc/testsuite/ChangeLog:

PR middle-end/97373
* gcc.dg/tree-ssa/builtin-sprintf-warn-25.c: New test.
gcc/builtins.c
gcc/builtins.h
gcc/gimple-ssa-sprintf.c
gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-25.c [new file with mode: 0644]
gcc/tree-ssa-strlen.c
gcc/tree-ssa-strlen.h