Re: C++ PATCH for c++/70153 (unhandled UNARY_PLUS_EXPR causes stack overflow)

2016-03-10 Thread Marek Polacek
On Thu, Mar 10, 2016 at 09:59:07AM -0500, Jason Merrill wrote: > On 03/10/2016 09:53 AM, Marek Polacek wrote: > >+case UNARY_PLUS_EXPR: > >+ op0 = cp_fold_maybe_rvalue (TREE_OPERAND (x, 0), rval_ops); > > You can just use cp_fold_rvalue here. OK with that change. Thanks. Final patch I'

Re: C++ PATCH for c++/70153 (unhandled UNARY_PLUS_EXPR causes stack overflow)

2016-03-10 Thread Jason Merrill
On 03/10/2016 09:53 AM, Marek Polacek wrote: +case UNARY_PLUS_EXPR: + op0 = cp_fold_maybe_rvalue (TREE_OPERAND (x, 0), rval_ops); You can just use cp_fold_rvalue here. OK with that change. Jason

Re: C++ PATCH for c++/70153 (unhandled UNARY_PLUS_EXPR causes stack overflow)

2016-03-10 Thread Marek Polacek
On Thu, Mar 10, 2016 at 09:34:17AM -0500, Jason Merrill wrote: > On 03/10/2016 08:07 AM, Marek Polacek wrote: > >On Thu, Mar 10, 2016 at 01:56:41PM +0100, Jakub Jelinek wrote: > >>On Thu, Mar 10, 2016 at 01:46:45PM +0100, Marek Polacek wrote: > >>>2016-03-10 Marek Polacek > >>> > >>> PR c++/70

Re: C++ PATCH for c++/70153 (unhandled UNARY_PLUS_EXPR causes stack overflow)

2016-03-10 Thread Jason Merrill
On 03/10/2016 08:07 AM, Marek Polacek wrote: On Thu, Mar 10, 2016 at 01:56:41PM +0100, Jakub Jelinek wrote: On Thu, Mar 10, 2016 at 01:46:45PM +0100, Marek Polacek wrote: 2016-03-10 Marek Polacek PR c++/70153 * cp-gimplify.c (cp_fold): Handle UNARY_PLUS_EXPR. * g++.

Re: C++ PATCH for c++/70153 (unhandled UNARY_PLUS_EXPR causes stack overflow)

2016-03-10 Thread Marek Polacek
On Thu, Mar 10, 2016 at 01:56:41PM +0100, Jakub Jelinek wrote: > On Thu, Mar 10, 2016 at 01:46:45PM +0100, Marek Polacek wrote: > > 2016-03-10 Marek Polacek > > > > PR c++/70153 > > * cp-gimplify.c (cp_fold): Handle UNARY_PLUS_EXPR. > > > > * g++.dg/delayedfold/unary-plus1.C: New t

Re: C++ PATCH for c++/70153 (unhandled UNARY_PLUS_EXPR causes stack overflow)

2016-03-10 Thread Jakub Jelinek
On Thu, Mar 10, 2016 at 01:46:45PM +0100, Marek Polacek wrote: > 2016-03-10 Marek Polacek > > PR c++/70153 > * cp-gimplify.c (cp_fold): Handle UNARY_PLUS_EXPR. > > * g++.dg/delayedfold/unary-plus1.C: New test. > > diff --git gcc/cp/cp-gimplify.c gcc/cp/cp-gimplify.c > index

C++ PATCH for c++/70153 (unhandled UNARY_PLUS_EXPR causes stack overflow)

2016-03-10 Thread Marek Polacek
Here, we got ourselves into infinite recursion in fold, resulting in a stack overflow. I believe the crux is that we're passing UNARY_PLUS_EXPR, a C++-only code, into fold which can't really fold e.g. 1 + UNARY_PLUS_EXPR <1>. I think cp_fold should be able to fold this to 2, but currently is not.