diff options
author | Martin Sebor <msebor@redhat.com> | 2019-11-05 17:05:33 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2019-11-05 10:05:33 -0700 |
commit | 8299dfae9364468096a8005c4b3a83d4fa0f6e42 (patch) | |
tree | 91b38228622227e0e765dfeb1f81e4a365f3ae48 /gcc/tree-ssa-ccp.c | |
parent | 3fd4f9242d9b7d2032126dc4851b4fdf5628dc35 (diff) | |
download | gcc-8299dfae9364468096a8005c4b3a83d4fa0f6e42.zip gcc-8299dfae9364468096a8005c4b3a83d4fa0f6e42.tar.gz gcc-8299dfae9364468096a8005c4b3a83d4fa0f6e42.tar.bz2 |
PR middle-end/92333 - missing variable name referencing VLA in warnings
PR middle-end/92333 - missing variable name referencing VLA in warnings
PR middle-end/82608 - missing -Warray-bounds on an out-of-bounds VLA index
gcc/testsuite/ChangeLog:
PR middle-end/92333
PR middle-end/82608
* gcc.dg/Warray-bounds-51.c: New test.
gcc/ChangeLog:
PR middle-end/92333
PR middle-end/82608
* tree-vrp.c (vrp_prop::check_array_ref): Handle VLAs with constant
size.
* tree-ssa-ccp.c (fold_builtin_alloca_with_align): Use a meaninful
name and location for a temporary variable.
From-SVN: r277854
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r-- | gcc/tree-ssa-ccp.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index a8d0738..567aef8 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -2222,7 +2222,25 @@ fold_builtin_alloca_with_align (gimple *stmt) elem_type = build_nonstandard_integer_type (BITS_PER_UNIT, 1); n_elem = size * 8 / BITS_PER_UNIT; array_type = build_array_type_nelts (elem_type, n_elem); - var = create_tmp_var (array_type); + + if (tree ssa_name = SSA_NAME_IDENTIFIER (lhs)) + { + /* Give the temporary a name derived from the name of the VLA + declaration so it can be referenced in diagnostics. */ + const char *name = IDENTIFIER_POINTER (ssa_name); + var = create_tmp_var (array_type, name); + } + else + var = create_tmp_var (array_type); + + if (gimple *lhsdef = SSA_NAME_DEF_STMT (lhs)) + { + /* Set the temporary's location to that of the VLA declaration + so it can be pointed to in diagnostics. */ + location_t loc = gimple_location (lhsdef); + DECL_SOURCE_LOCATION (var) = loc; + } + SET_DECL_ALIGN (var, TREE_INT_CST_LOW (gimple_call_arg (stmt, 1))); if (uid != 0) SET_DECL_PT_UID (var, uid); |