[ Sorry for dropping the ball on this. ]

On Tue, Sep 17, 2019 at 11:59:02PM -0400, Jason Merrill wrote:
> On 9/16/19 1:12 PM, Marek Polacek wrote:
> > On Sun, Sep 15, 2019 at 10:18:29AM -0400, Jason Merrill wrote:
> > > On 9/5/19 9:24 PM, Marek Polacek wrote:
> > > > They use
> > > > non_lvalue_loc, but that won't create a NON_LVALUE_EXPR wrapper around 
> > > > a location
> > > > wrapper.
> > > 
> > > That seems like the bug. maybe_lvalue_p should be true for
> > > VIEW_CONVERT_EXPR.
> > 
> > That makes sense but it breaks in tsubst_* which doesn't expect a
> > NON_LVALUE_EXPR wrapped around a location wrapper.
> 
> Hmm, why would we get that in a template when we don't get NON_LVALUE_EXPR
> wrapped around other lvalue nodes?

I just retested the patch without the pt.c hunk and no longer see that problem,
and the fold-const.c hunk still fixes the bogus error.  Yay?

So I think the following should be good to go:

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

2019-12-06  Marek Polacek  <pola...@redhat.com>

        PR c++/91678 - wrong error with decltype and location wrapper.
        * fold-const.c (maybe_lvalue_p): Handle VIEW_CONVERT_EXPR.

        * g++.dg/cpp0x/decltype73.C: New test.

--- gcc/fold-const.c
+++ gcc/fold-const.c
@@ -2594,6 +2594,7 @@ maybe_lvalue_p (const_tree x)
   case TARGET_EXPR:
   case COND_EXPR:
   case BIND_EXPR:
+  case VIEW_CONVERT_EXPR:
     break;
 
   default:
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp0x/decltype73.C
@@ -0,0 +1,4 @@
+// PR c++/91678 - wrong error with decltype and location wrapper.
+// { dg-do compile { target c++11 } }
+
+float* test(float* c) { return (decltype(c + 0))(float*)c; }

Reply via email to