]> git.ipfire.org Git - thirdparty/gcc.git/commit
Improve/correct detection of overlapping aggregates [PR102238, PR102919].
authorMartin Sebor <msebor@redhat.com>
Tue, 26 Oct 2021 20:40:33 +0000 (14:40 -0600)
committerMartin Sebor <msebor@redhat.com>
Tue, 26 Oct 2021 22:53:54 +0000 (16:53 -0600)
commit1ff4dbddcf74203a1e16316b18e12f9e1b5085f0
tree5f6066e4ea74c6ac5a9a3e6e52ae5abb0a6cc95b
parent9a27acc30a34b7854db32eac562306cebac6fa1e
Improve/correct detection of overlapping aggregates [PR102238, PR102919].

Resolves:
PR tree-optimization/102238 - alias_offset in gimple-ssa-sprintf.c is broken
PR tree-optimization/102919 - spurious -Wrestrict warning for sprintf into the same member array as argument plus offset

gcc/ChangeLog:

PR tree-optimization/102238
PR tree-optimization/102919
* gimple-ssa-sprintf.c (get_string_length): Add an argument.
(array_elt_at_offset): Move to pointer-query.
(set_aggregate_size_and_offset): New function.
(field_at_offset):  Move to pointer-query.
(get_origin_and_offset): Rename...
(get_origin_and_offset_r): this.  Add an argument.  Make aggregate
handling more robust.
(get_origin_and_offset): New.
(alias_offset): Add an argument.
(format_string): Use subobject size determined by get_origin_and_offset.
* pointer-query.cc (field_at_offset): Move from gimple-ssa-sprintf.c.
Improve/correct handling of aggregates.
(array_elt_at_offset): Same.
* pointer-query.h (field_at_offset): Declare.
(array_elt_at_offset): Declare.

gcc/testsuite/ChangeLog:

PR tree-optimization/102238
PR tree-optimization/102919
* gcc.dg/tree-ssa/builtin-sprintf-warn-23.c: Remove warnings.
* gcc.dg/Wrestrict-23.c: New test.
gcc/gimple-ssa-sprintf.c
gcc/pointer-query.cc
gcc/pointer-query.h
gcc/testsuite/gcc.dg/Wrestrict-23.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-23.c