PR middle-end/88226 - missing warning on fprintf, fputs, and puts with an unterminate...
authorMartin Sebor <msebor@redhat.com>
Fri, 22 Nov 2019 16:47:22 +0000 (16:47 +0000)
committerMartin Sebor <msebor@gcc.gnu.org>
Fri, 22 Nov 2019 16:47:22 +0000 (09:47 -0700)
commitb5338fb359ea3480d6ed37bbc52fe2df49b82fb9
tree2216f90a2e8eee2cdeb3d613c5d53dc9e791f4a9
parent86b0eb81837f4912d3f10bcfad35086cc54a1841
PR middle-end/88226 - missing warning on fprintf, fputs, and puts with an unterminated array

gcc/ChangeLog:

PR middle-end/88226
* builtins.c (check_nul_terminated_array): New function.
(fold_builtin_0): Remove declaration.
(fold_builtin_1): Same.
(fold_builtin_2): Same.
(fold_builtin_3): Same.
(fold_builtin_strpbrk): Add argument.
(fold_builtin_strspn): Same.
(fold_builtin_strcspn): Same.
(expand_builtin_strcat): Call it.  Remove unused argument.
(expand_builtin_stpncpy): Same.
(expand_builtin_strncat): Same.
(expand_builtin_strncpy): Same.  Adjust indentation.
(expand_builtin_strcmp): Same.
(expand_builtin_strncmp): Same.
(expand_builtin_fork_or_exec): Same.
(expand_builtin): Handle more built-ins.
(fold_builtin_2): Add argument.
(fold_builtin_n): Make static.  Add argument.
(fold_call_expr): Pass new argument to fold_builtin_n and fold_builtin_2.
(fold_builtin_call_array): Pass new argument to fold_builtin_n.
(fold_builtin_strpbrk): Add argument.  Call check_nul_terminated_array.
(fold_call_stmt): Pass new argument to fold_builtin_n.
* builtins.h: Correct a comment.
* gimple-fold.c (gimple_fold_builtin_strchr): Call
check_nul_terminated_array.
* tree-ssa-strlen.c (handle_builtin_strlen): Call
check_nul_terminated_array.
(handle_builtin_strchr): Same.
(handle_builtin_string_cmp): Same.

gcc/testsuite/ChangeLog:

PR middle-end/88226
* gcc.dg/Wstringop-overflow-22.c: New test.
* gcc.dg/tree-ssa/builtin-fprintf-warn-1.c: Remove xfails.

From-SVN: r278623
gcc/ChangeLog
gcc/builtins.c
gcc/builtins.h
gcc/gimple-fold.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wstringop-overflow-22.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/builtin-fprintf-warn-1.c
gcc/tree-ssa-strlen.c