aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-array-bounds.cc
AgeCommit message (Collapse)AuthorFilesLines
2020-09-23Build a zero element array type that reliably renders as T[0] in diagnostcs.Martin Sebor1-1/+18
gcc/ChangeLog: * gimple-array-bounds.cc (build_zero_elt_array_type): New function. (array_bounds_checker::check_mem_ref): Call it.
2020-09-19Extend -Warray-bounds to detect out-of-bounds accesses to array parameters.Martin Sebor1-77/+334
gcc/ChangeLog: PR middle-end/82608 PR middle-end/94195 PR c/50584 PR middle-end/84051 * gimple-array-bounds.cc (get_base_decl): New function. (get_ref_size): New function. (trailing_array): New function. (array_bounds_checker::check_array_ref): Call them. Handle arrays declared in function parameters. (array_bounds_checker::check_mem_ref): Same. Handle references to dynamically allocated arrays. gcc/testsuite/ChangeLog: PR middle-end/82608 PR middle-end/94195 PR c/50584 PR middle-end/84051 * c-c++-common/Warray-bounds.c: Adjust. * gcc.dg/Wbuiltin-declaration-mismatch-9.c: Adjust. * gcc.dg/Warray-bounds-63.c: New test. * gcc.dg/Warray-bounds-64.c: New test. * gcc.dg/Warray-bounds-65.c: New test. * gcc.dg/Warray-bounds-66.c: New test. * gcc.dg/Warray-bounds-67.c: New test.
2020-07-27Diagnose just-past-the-end references for minor array bounds.Martin Sebor1-2/+9
Resolves: PR tree-optimization/84079 - missing -Warray-bounds taking the address of past-the-end element of a multidimensional array gcc/ChangeLog: PR tree-optimization/84079 * gimple-array-bounds.cc (array_bounds_checker::check_addr_expr): Only allow just-past-the-end references for the most significant array bound. gcc/testsuite/ChangeLog: PR tree-optimization/84079 * gcc.dg/Warray-bounds-62.c: New test.
2020-06-01Move array bounds checking into its own file.Aldy Hernandez1-0/+700
gcc/ * Makefile.in (gimple-array-bounds.o): New. * tree-vrp.c: Move array bounds code... * gimple-array-bounds.cc: ...here... * gimple-array-bounds.h: ...and here.