]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR middle-end/65984 (ICE: definition in block 4 does not dominate use...
authorJakub Jelinek <jakub@redhat.com>
Wed, 3 Jun 2015 15:33:59 +0000 (17:33 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 3 Jun 2015 15:33:59 +0000 (17:33 +0200)
Backported from mainline
2015-05-04  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/65984
* ubsan.c: Include tree-cfg.h.
(instrument_bool_enum_load): Use stmt_ends_bb_p instead of
stmt_could_throw_p test, rename can_throw variable to ends_bb.

* c-c++-common/ubsan/pr65984.c: New test.

From-SVN: r224092

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/ubsan/pr65984.c [new file with mode: 0644]
gcc/ubsan.c

index 2f68b618c7d1dec862ffd4f4d83802363e1d8cb0..cf6b60c4c2a085427c0a0a15127d53716422bbff 100644 (file)
@@ -1,6 +1,13 @@
 2015-06-03  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2015-05-04  Jakub Jelinek  <jakub@redhat.com>
+       PR tree-optimization/65984
+       * ubsan.c: Include tree-cfg.h.
+       (instrument_bool_enum_load): Use stmt_ends_bb_p instead of
+       stmt_could_throw_p test, rename can_throw variable to ends_bb.
+
        2015-04-07  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/65680
index 7717db9c12c3d33040b16daffd624583bd0bdf56..c69ce9c11602e7d7d6dd3cee5d741f6eda9b5ea9 100644 (file)
@@ -1,6 +1,11 @@
 2015-06-03  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2015-05-04  Jakub Jelinek  <jakub@redhat.com>
+       PR tree-optimization/65984
+       * c-c++-common/ubsan/pr65984.c: New test.
+
        2015-04-07  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/65680
diff --git a/gcc/testsuite/c-c++-common/ubsan/pr65984.c b/gcc/testsuite/c-c++-common/ubsan/pr65984.c
new file mode 100644 (file)
index 0000000..94ba011
--- /dev/null
@@ -0,0 +1,23 @@
+/* PR tree-optimization/65984 */
+/* { dg-do compile } */
+/* { dg-options "-fnon-call-exceptions -fsanitize=bool,enum" } */
+
+#ifndef __cplusplus
+#define bool _Bool
+#endif
+
+enum E { E0, E1, E2 };
+enum E e[2];
+bool *b;
+
+int
+foo (int i)
+{
+  return e[i];
+}
+
+int
+bar (int i)
+{
+  return b[i];
+}
index 25c2cde60401790c6cd1df4b28a19360ec7baa2c..106cba41ead4bb3d5da59522608b8bac9a3137f0 100644 (file)
@@ -48,6 +48,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimplify-me.h"
 #include "intl.h"
 #include "tree-eh.h"
+#include "tree-cfg.h"
 
 /* Map from a tree to a VAR_DECL tree.  */
 
@@ -808,7 +809,7 @@ instrument_bool_enum_load (gimple_stmt_iterator *gsi)
       || TREE_CODE (gimple_assign_lhs (stmt)) != SSA_NAME)
     return;
 
-  bool can_throw = stmt_could_throw_p (stmt);
+  bool ends_bb = stmt_ends_bb_p (stmt);
   location_t loc = gimple_location (stmt);
   tree lhs = gimple_assign_lhs (stmt);
   tree ptype = build_pointer_type (TREE_TYPE (rhs));
@@ -820,7 +821,7 @@ instrument_bool_enum_load (gimple_stmt_iterator *gsi)
   tree mem = build2 (MEM_REF, utype, gimple_assign_lhs (g),
                     build_int_cst (atype, 0));
   tree urhs = make_ssa_name (utype, NULL);
-  if (can_throw)
+  if (ends_bb)
     {
       gimple_assign_set_lhs (stmt, urhs);
       g = gimple_build_assign_with_ops (NOP_EXPR, lhs, urhs, NULL_TREE);
@@ -859,7 +860,7 @@ instrument_bool_enum_load (gimple_stmt_iterator *gsi)
   gimple_set_location (g, loc);
   gsi_insert_after (gsi, g, GSI_NEW_STMT);
 
-  if (!can_throw)
+  if (!ends_bb)
     {
       gimple_assign_set_rhs_with_ops (&gsi2, NOP_EXPR, urhs, NULL_TREE);
       update_stmt (stmt);