diff options
author | Martin Sebor <msebor@redhat.com> | 2021-11-17 15:09:23 -0700 |
---|---|---|
committer | Martin Sebor <msebor@redhat.com> | 2021-11-17 15:09:23 -0700 |
commit | ea9e0d6c27405d256b4888e9e860e469037c911d (patch) | |
tree | acc04c95beb0bfed36eed47bb3a5131d09815bde /gcc/gimple-array-bounds.cc | |
parent | 53a643f8568067d7700a9f2facc8ba39974973d3 (diff) | |
download | gcc-ea9e0d6c27405d256b4888e9e860e469037c911d.zip gcc-ea9e0d6c27405d256b4888e9e860e469037c911d.tar.gz gcc-ea9e0d6c27405d256b4888e9e860e469037c911d.tar.bz2 |
Avoid pathological function redeclarations when checking access sizes [PR102759].
Resolves:
PR tree-optimization/102759 - ICE: Segmentation fault in maybe_check_access_sizes since r12-2976-gb48d4e6818674898
gcc/ChangeLog:
PR tree-optimization/102759
* gimple-array-bounds.cc (build_printable_array_type): Move...
* gimple-ssa-warn-access.cc (build_printable_array_type): Avoid
pathological function redeclarations that remove a previously
declared prototype.
Improve formatting of function arguments in informational notes.
* pointer-query.cc (build_printable_array_type): ...to here.
* pointer-query.h (build_printable_array_type): Declared.
gcc/testsuite/ChangeLog:
PR tree-optimization/102759
* gcc.dg/Warray-parameter-10.c: New test.
* gcc.dg/Wstringop-overflow-82.c: New test.
Diffstat (limited to 'gcc/gimple-array-bounds.cc')
-rw-r--r-- | gcc/gimple-array-bounds.cc | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/gcc/gimple-array-bounds.cc b/gcc/gimple-array-bounds.cc index a353559..ddb99d2 100644 --- a/gcc/gimple-array-bounds.cc +++ b/gcc/gimple-array-bounds.cc @@ -372,31 +372,6 @@ array_bounds_checker::check_array_ref (location_t location, tree ref, return warned; } -/* Wrapper around build_array_type_nelts that makes sure the array - can be created at all and handles zero sized arrays specially. */ - -static tree -build_printable_array_type (tree eltype, unsigned HOST_WIDE_INT nelts) -{ - if (TYPE_SIZE_UNIT (eltype) - && TREE_CODE (TYPE_SIZE_UNIT (eltype)) == INTEGER_CST - && !integer_zerop (TYPE_SIZE_UNIT (eltype)) - && TYPE_ALIGN_UNIT (eltype) > 1 - && wi::zext (wi::to_wide (TYPE_SIZE_UNIT (eltype)), - ffs_hwi (TYPE_ALIGN_UNIT (eltype)) - 1) != 0) - eltype = TYPE_MAIN_VARIANT (eltype); - - if (nelts) - return build_array_type_nelts (eltype, nelts); - - tree idxtype = build_range_type (sizetype, size_zero_node, NULL_TREE); - tree arrtype = build_array_type (eltype, idxtype); - arrtype = build_distinct_type_copy (TYPE_MAIN_VARIANT (arrtype)); - TYPE_SIZE (arrtype) = bitsize_zero_node; - TYPE_SIZE_UNIT (arrtype) = size_zero_node; - return arrtype; -} - /* Checks one MEM_REF in REF, located at LOCATION, for out-of-bounds references to string constants. If VRP can determine that the array subscript is a constant, check if it is outside valid range. |