On Wed, Mar 01, 2023 at 04:53:23PM -0500, Jason Merrill wrote: > > @@ -13791,12 +13830,39 @@ std_pair_ref_ref_p (tree t) > > const int& y = (f(1), 42); // NULL_TREE > > const int& z = f(f(1)); // f(f(1)) > > - EXPR is the initializer. */ > > + EXPR is the initializer. If ARG_P is true, we're processing an argument > > + to a function; the point is to distinguish between, for example, > > + > > + Ref::inner (&TARGET_EXPR <D.2839, F::foo (fm)>) > > + > > + where we shouldn't warn, and > > + > > + Ref::inner (&TARGET_EXPR <D.2908, F::foo (&TARGET_EXPR <...>)>) > > + > > + where we should warn (Ref is a reference_like_class_p so we see through > > + it. */ > > static tree > > -do_warn_dangling_reference (tree expr) > > +do_warn_dangling_reference (tree expr, bool arg_p) > > { > > STRIP_NOPS (expr); > > + if (TREE_CODE (expr) == ADDR_EXPR) > > + expr = TREE_OPERAND (expr, 0); > > I think if we move this here, we also need to check that expr before > STRIP_NOPS had REFERENCE_TYPE. OK with that change.
Sorry but I don't think I can do that. There can be CONVERT_EXPRs that need to be stripped, whether arg_p or !arg_p. For example, we can get (const int *) f ((const int &) &TARGET_EXPR <D.2765, NON_LVALUE_EXPR <10>>) for const int& r5 = (42, f(10)); Is the patch OK as-is then? Marek