public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR69801
@ 2016-02-16  8:35 Richard Biener
  2016-02-16 15:36 ` Jakub Jelinek
  2016-02-16 17:39 ` H.J. Lu
  0 siblings, 2 replies; 4+ messages in thread
From: Richard Biener @ 2016-02-16  8:35 UTC (permalink / raw)
  To: gcc-patches


Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2016-02-16  Richard Biener  <rguenther@suse.de>

	PR middle-end/69801
	* fold-const.c (operand_equal_p): For COND_EXPR zero operand
	mask OEP_ADDRESS_OF.

	* gcc.dg/pr69801.c: New testcase.

Index: gcc/fold-const.c
===================================================================
*** gcc/fold-const.c	(revision 233418)
--- gcc/fold-const.c	(working copy)
*************** operand_equal_p (const_tree arg0, const_
*** 3118,3123 ****
--- 3118,3128 ----
  				      TREE_OPERAND (arg1, 0), flags));
  
  	case COND_EXPR:
+ 	  if (! OP_SAME (1) || ! OP_SAME (2))
+ 	    return 0;
+ 	  flags &= ~OEP_ADDRESS_OF;
+ 	  return OP_SAME (0);
+ 
  	case VEC_COND_EXPR:
  	case DOT_PROD_EXPR:
  	  return OP_SAME (0) && OP_SAME (1) && OP_SAME (2);
Index: gcc/testsuite/gcc.dg/pr69801.c
===================================================================
*** gcc/testsuite/gcc.dg/pr69801.c	(revision 0)
--- gcc/testsuite/gcc.dg/pr69801.c	(working copy)
***************
*** 0 ****
--- 1,7 ----
+ /* { dg-do compile } */
+ 
+ struct {
+     char c[1];
+ } b, c;
+ int d, e;
+ void fn1() { e ? (d ? b : c).c : (d ? b : c).c; }

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

* Re: [PATCH] Fix PR69801
  2016-02-16  8:35 [PATCH] Fix PR69801 Richard Biener
@ 2016-02-16 15:36 ` Jakub Jelinek
  2016-02-16 17:39 ` H.J. Lu
  1 sibling, 0 replies; 4+ messages in thread
From: Jakub Jelinek @ 2016-02-16 15:36 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

On Tue, Feb 16, 2016 at 09:35:25AM +0100, Richard Biener wrote:
> 
> Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
> 
> Richard.
> 
> 2016-02-16  Richard Biener  <rguenther@suse.de>
> 
> 	PR middle-end/69801
> 	* fold-const.c (operand_equal_p): For COND_EXPR zero operand
> 	mask OEP_ADDRESS_OF.
> 
> 	* gcc.dg/pr69801.c: New testcase.

The testcase fails, because default options include -ansi -pedantic-errors
and the testcase isn't valid C89.

Fixed thusly, regtested on x86_64-linux, committed to trunk as obvious.

2016-02-16  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/69801
	* gcc.dg/pr69801.c: Add empty dg-options.

--- gcc/testsuite/gcc.dg/pr69801.c.jj	2016-02-16 10:11:14.000000000 +0100
+++ gcc/testsuite/gcc.dg/pr69801.c	2016-02-16 16:32:30.955386927 +0100
@@ -1,4 +1,6 @@
+/* PR middle-end/69801 */
 /* { dg-do compile } */
+/* { dg-options "" } */
 
 struct {
     char c[1];


	Jakub

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

* Re: [PATCH] Fix PR69801
  2016-02-16  8:35 [PATCH] Fix PR69801 Richard Biener
  2016-02-16 15:36 ` Jakub Jelinek
@ 2016-02-16 17:39 ` H.J. Lu
  2016-02-16 17:42   ` Marek Polacek
  1 sibling, 1 reply; 4+ messages in thread
From: H.J. Lu @ 2016-02-16 17:39 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches

On Tue, Feb 16, 2016 at 12:35 AM, Richard Biener <rguenther@suse.de> wrote:
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
>
> Richard.
>
> 2016-02-16  Richard Biener  <rguenther@suse.de>
>
>         PR middle-end/69801
>         * fold-const.c (operand_equal_p): For COND_EXPR zero operand
>         mask OEP_ADDRESS_OF.
>
>         * gcc.dg/pr69801.c: New testcase.
>
> Index: gcc/fold-const.c
> ===================================================================
> *** gcc/fold-const.c    (revision 233418)
> --- gcc/fold-const.c    (working copy)
> *************** operand_equal_p (const_tree arg0, const_
> *** 3118,3123 ****
> --- 3118,3128 ----
>                                       TREE_OPERAND (arg1, 0), flags));
>
>         case COND_EXPR:
> +         if (! OP_SAME (1) || ! OP_SAME (2))
> +           return 0;
> +         flags &= ~OEP_ADDRESS_OF;
> +         return OP_SAME (0);
> +
>         case VEC_COND_EXPR:
>         case DOT_PROD_EXPR:
>           return OP_SAME (0) && OP_SAME (1) && OP_SAME (2);
> Index: gcc/testsuite/gcc.dg/pr69801.c
> ===================================================================
> *** gcc/testsuite/gcc.dg/pr69801.c      (revision 0)
> --- gcc/testsuite/gcc.dg/pr69801.c      (working copy)
> ***************
> *** 0 ****
> --- 1,7 ----
> + /* { dg-do compile } */
> +
> + struct {
> +     char c[1];
> + } b, c;
> + int d, e;
> + void fn1() { e ? (d ? b : c).c : (d ? b : c).c; }

I got

output is:
/export/gnu/import/git/gcc-test-ia32corei7/src-trunk/gcc/testsuite/gcc.dg/pr69801.c:
In function 'fn1':^M
/export/gnu/import/git/gcc-test-ia32corei7/src-trunk/gcc/testsuite/gcc.dg/pr69801.c:7:32:
error: non-lvalue array in conditional expression^M

FAIL: gcc.dg/pr69801.c (test for excess errors)

-- 
H.J.

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

* Re: [PATCH] Fix PR69801
  2016-02-16 17:39 ` H.J. Lu
@ 2016-02-16 17:42   ` Marek Polacek
  0 siblings, 0 replies; 4+ messages in thread
From: Marek Polacek @ 2016-02-16 17:42 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Richard Biener, GCC Patches

On Tue, Feb 16, 2016 at 09:39:10AM -0800, H.J. Lu wrote:
 > Index: gcc/testsuite/gcc.dg/pr69801.c
> > ===================================================================
> > *** gcc/testsuite/gcc.dg/pr69801.c      (revision 0)
> > --- gcc/testsuite/gcc.dg/pr69801.c      (working copy)
> > ***************
> > *** 0 ****
> > --- 1,7 ----
> > + /* { dg-do compile } */
> > +
> > + struct {
> > +     char c[1];
> > + } b, c;
> > + int d, e;
> > + void fn1() { e ? (d ? b : c).c : (d ? b : c).c; }
> 
> I got
> 
> output is:
> /export/gnu/import/git/gcc-test-ia32corei7/src-trunk/gcc/testsuite/gcc.dg/pr69801.c:
> In function 'fn1':^M
> /export/gnu/import/git/gcc-test-ia32corei7/src-trunk/gcc/testsuite/gcc.dg/pr69801.c:7:32:
> error: non-lvalue array in conditional expression^M
> 
> FAIL: gcc.dg/pr69801.c (test for excess errors)

Should be already fixed:
https://gcc.gnu.org/ml/gcc-patches/2016-02/msg01084.html

	Marek

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

end of thread, other threads:[~2016-02-16 17:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-16  8:35 [PATCH] Fix PR69801 Richard Biener
2016-02-16 15:36 ` Jakub Jelinek
2016-02-16 17:39 ` H.J. Lu
2016-02-16 17:42   ` Marek Polacek

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).