PR middle-end/92622 - FAIL: gcc.dg/Warray-bounds-22.c on ILP32: missing warnings...
authorMartin Sebor <msebor@redhat.com>
Fri, 6 Dec 2019 00:18:32 +0000 (00:18 +0000)
committerMartin Sebor <msebor@gcc.gnu.org>
Fri, 6 Dec 2019 00:18:32 +0000 (17:18 -0700)
gcc/ChangeLog:

PR middle-end/92622
* tree-vrp.c (vrp_prop::check_array_ref): Avoid using a variable
left uninitialized by get_addr_base_and_unit_offset ofn failure.

From-SVN: r279029

gcc/ChangeLog
gcc/tree-vrp.c

index ba64864f1d2b1bddd98a37a5e83c1f8e7b0c7c2e..31b03fffff251d5c7b55e1d2bb6cf84db53d3413 100644 (file)
@@ -1,3 +1,9 @@
+2019-12-05  Martin Sebor  <msebor@redhat.com>
+
+       PR middle-end/92622
+       * tree-vrp.c (vrp_prop::check_array_ref): Avoid using a variable
+       left uninitialized by get_addr_base_and_unit_offset on failure.
+
 2019-12-05  Jan Hubicka  <hubicka@ucw.cz>
 
        * ipa-prop.c (ipa_set_jf_unknown): Do not clear bits and m_vr.
        (ipa_update_overall_fn_summary): Add RESET parameter.
        * ipa-fnsummary.h (ipa_update_overall_fn_summary): Update prototype.
        * ipa-inline-transform.c (inline_call): Enable incremental updates.
-       
+
 2019-11-20  Richard Sandiford  <richard.sandiford@arm.com>
 
        * tree-vect-slp.c (vect_schedule_slp_instance): Restore stmt
index bbcf237a925aa186c4df13e736b63bfad992390c..cce63155b6c48cf36641ab7eabef07b4351bbabf 100644 (file)
@@ -3516,7 +3516,6 @@ vrp_prop::check_array_ref (location_t location, tree ref,
          tree ptrdiff_max = TYPE_MAX_VALUE (ptrdiff_type_node);
          tree maxbound = ptrdiff_max;
          tree arg = TREE_OPERAND (ref, 0);
-         poly_int64 off;
 
          const bool compref = TREE_CODE (arg) == COMPONENT_REF;
          if (compref)
@@ -3535,19 +3534,22 @@ vrp_prop::check_array_ref (location_t location, tree ref,
                 size wouldn't necessarily be correct if the reference is
                 to its flexible array member initialized in a different
                 translation unit.  */
-             tree base = get_addr_base_and_unit_offset (arg, &off);
-             if (!compref && base && DECL_P (base))
-               if (tree basesize = DECL_SIZE_UNIT (base))
-                 if (TREE_CODE (basesize) == INTEGER_CST)
-                   {
-                     maxbound = basesize;
-                     decl = base;
-                   }
-
-             if (known_gt (off, 0))
-               maxbound = wide_int_to_tree (sizetype,
-                                            wi::sub (wi::to_wide (maxbound),
-                                                     off));
+             poly_int64 off;
+             if (tree base = get_addr_base_and_unit_offset (arg, &off))
+               {
+                 if (!compref && DECL_P (base))
+                   if (tree basesize = DECL_SIZE_UNIT (base))
+                     if (TREE_CODE (basesize) == INTEGER_CST)
+                       {
+                         maxbound = basesize;
+                         decl = base;
+                       }
+
+                 if (known_gt (off, 0))
+                   maxbound = wide_int_to_tree (sizetype,
+                                                wi::sub (wi::to_wide (maxbound),
+                                                         off));
+               }
            }
          else
            maxbound = fold_convert (sizetype, maxbound);