]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport r246276
authorMartin Liska <mliska@suse.cz>
Wed, 22 Mar 2017 12:32:17 +0000 (13:32 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Wed, 22 Mar 2017 12:32:17 +0000 (12:32 +0000)
2017-03-22  Martin Liska  <mliska@suse.cz>

Backport from mainline
2017-03-20  Martin Liska  <mliska@suse.cz>

PR middle-end/79753
* tree-chkp.c (chkp_build_returned_bound): Do not build
returned bounds for a LHS that's not a BOUNDED_P type.
2017-03-22  Martin Liska  <mliska@suse.cz>

Backport from mainline
2017-03-20  Martin Liska  <mliska@suse.cz>

PR middle-end/79753
* gcc.target/i386/mpx/pr79753.c: New test.

From-SVN: r246377

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/mpx/pr79753.c [new file with mode: 0644]
gcc/tree-chkp.c

index f47095e9bfa1662a2044b0bf71e129c04c2eefba..fbfe18f9947f6e835f1b248a6c4ac4b4e37eeff0 100644 (file)
@@ -1,3 +1,12 @@
+2017-03-22  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       2017-03-20  Martin Liska  <mliska@suse.cz>
+
+       PR middle-end/79753
+       * tree-chkp.c (chkp_build_returned_bound): Do not build
+       returned bounds for a LHS that's not a BOUNDED_P type.
+
 2017-03-22  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
index 416cddc5a575cd46cb8bb734219b269d33de0681..e9ef670f87b24fb453d68f6a7e58d74ef0a3c0cb 100644 (file)
@@ -1,3 +1,11 @@
+2017-03-22  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       2017-03-20  Martin Liska  <mliska@suse.cz>
+
+       PR middle-end/79753
+       * gcc.target/i386/mpx/pr79753.c: New test.
+
 2017-03-22  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr79753.c b/gcc/testsuite/gcc.target/i386/mpx/pr79753.c
new file mode 100644 (file)
index 0000000..9b7bc52
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -O2" } */
+
+int
+foo (void)
+{
+  return 0;
+}
+
+void
+bar (int **p)
+{
+  *p = (int *) (__UINTPTR_TYPE__) foo ();
+}
index 39a9f62df536402830b5e40faf7d58bfdb6ce303..824827768f48bc8169a73b43ce56cbb3fd80a6d0 100644 (file)
@@ -2236,6 +2236,7 @@ chkp_build_returned_bound (gcall *call)
   tree bounds;
   gimple stmt;
   tree fndecl = gimple_call_fndecl (call);
+  tree lhs = gimple_call_lhs (call);
   unsigned int retflags;
 
   /* To avoid fixing alloca expands in targets we handle
@@ -2246,9 +2247,8 @@ chkp_build_returned_bound (gcall *call)
          || DECL_FUNCTION_CODE (fndecl) == BUILT_IN_ALLOCA_WITH_ALIGN))
     {
       tree size = gimple_call_arg (call, 0);
-      tree lb = gimple_call_lhs (call);
       gimple_stmt_iterator iter = gsi_for_stmt (call);
-      bounds = chkp_make_bounds (lb, size, &iter, true);
+      bounds = chkp_make_bounds (lhs, size, &iter, true);
     }
   /* We know bounds returned by set_bounds builtin call.  */
   else if (fndecl
@@ -2301,9 +2301,10 @@ chkp_build_returned_bound (gcall *call)
 
       bounds = chkp_find_bounds (gimple_call_arg (call, argno), &iter);
     }
-  else if (chkp_call_returns_bounds_p (call))
+  else if (chkp_call_returns_bounds_p (call)
+          && BOUNDED_P (lhs))
     {
-      gcc_assert (TREE_CODE (gimple_call_lhs (call)) == SSA_NAME);
+      gcc_assert (TREE_CODE (lhs) == SSA_NAME);
 
       /* In general case build checker builtin call to
         obtain returned bounds.  */
@@ -2330,7 +2331,7 @@ chkp_build_returned_bound (gcall *call)
       print_gimple_stmt (dump_file, call, 0, TDF_VOPS|TDF_MEMSYMS);
     }
 
-  bounds = chkp_maybe_copy_and_register_bounds (gimple_call_lhs (call), bounds);
+  bounds = chkp_maybe_copy_and_register_bounds (lhs, bounds);
 
   return bounds;
 }