public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Handle POINTER_DIFF_EXPR in chkp
@ 2017-12-02  0:14 Jakub Jelinek
  2017-12-02  7:54 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2017-12-02  0:14 UTC (permalink / raw)
  To: Richard Biener, Ilya Enkovich, Kirill Yukhin; +Cc: gcc-patches

Hi!

The following testcase shows that chkp_compute_bounds_for_assignment
should know about POINTER_DIFF_EXPR and handle it like it used
to handle MINUS_EXPR of 2 pointers in the past.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2017-12-01  Jakub Jelinek  <jakub@redhat.com>

	* tree-chkp.c (chkp_compute_bounds_for_assignment): Handle
	POINTER_DIFF_EXPR.

	* gcc.target/i386/mpx/pointer-diff-1.c: New test.

--- gcc/tree-chkp.c.jj	2017-11-13 09:31:29.000000000 +0100
+++ gcc/tree-chkp.c	2017-12-01 15:11:40.331410514 +0100
@@ -2762,6 +2762,7 @@ chkp_compute_bounds_for_assignment (tree
     case FLOAT_EXPR:
     case REALPART_EXPR:
     case IMAGPART_EXPR:
+    case POINTER_DIFF_EXPR:
       /* No valid bounds may be produced by these exprs.  */
       bounds = chkp_get_invalid_op_bounds ();
       break;
--- gcc/testsuite/gcc.target/i386/mpx/pointer-diff-1.c.jj	2017-12-01 15:18:52.805002275 +0100
+++ gcc/testsuite/gcc.target/i386/mpx/pointer-diff-1.c	2017-12-01 15:17:35.000000000 +0100
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mmpx -fcheck-pointer-bounds" } */
+
+char *
+foo (char *p, char *q)
+{
+  return (char *) (p - q);	/* { dg-bogus "pointer bounds were lost due to unexpected expression" } */
+}

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Handle POINTER_DIFF_EXPR in chkp
  2017-12-02  0:14 [PATCH] Handle POINTER_DIFF_EXPR in chkp Jakub Jelinek
@ 2017-12-02  7:54 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2017-12-02  7:54 UTC (permalink / raw)
  To: Jakub Jelinek, Ilya Enkovich, Kirill Yukhin; +Cc: gcc-patches

On December 2, 2017 1:14:03 AM GMT+01:00, Jakub Jelinek <jakub@redhat.com> wrote:
>Hi!
>
>The following testcase shows that chkp_compute_bounds_for_assignment
>should know about POINTER_DIFF_EXPR and handle it like it used
>to handle MINUS_EXPR of 2 pointers in the past.
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK. 

Richard. 

>2017-12-01  Jakub Jelinek  <jakub@redhat.com>
>
>	* tree-chkp.c (chkp_compute_bounds_for_assignment): Handle
>	POINTER_DIFF_EXPR.
>
>	* gcc.target/i386/mpx/pointer-diff-1.c: New test.
>
>--- gcc/tree-chkp.c.jj	2017-11-13 09:31:29.000000000 +0100
>+++ gcc/tree-chkp.c	2017-12-01 15:11:40.331410514 +0100
>@@ -2762,6 +2762,7 @@ chkp_compute_bounds_for_assignment (tree
>     case FLOAT_EXPR:
>     case REALPART_EXPR:
>     case IMAGPART_EXPR:
>+    case POINTER_DIFF_EXPR:
>       /* No valid bounds may be produced by these exprs.  */
>       bounds = chkp_get_invalid_op_bounds ();
>       break;
>--- gcc/testsuite/gcc.target/i386/mpx/pointer-diff-1.c.jj	2017-12-01
>15:18:52.805002275 +0100
>+++ gcc/testsuite/gcc.target/i386/mpx/pointer-diff-1.c	2017-12-01
>15:17:35.000000000 +0100
>@@ -0,0 +1,8 @@
>+/* { dg-do compile } */
>+/* { dg-options "-O2 -mmpx -fcheck-pointer-bounds" } */
>+
>+char *
>+foo (char *p, char *q)
>+{
>+  return (char *) (p - q);	/* { dg-bogus "pointer bounds were lost due
>to unexpected expression" } */
>+}
>
>	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-02  7:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-02  0:14 [PATCH] Handle POINTER_DIFF_EXPR in chkp Jakub Jelinek
2017-12-02  7:54 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).