On Tue, Sep 28, 2021 at 06:49:38PM +0200, Jakub Jelinek via Gcc-patches wrote:
> On Tue, Sep 28, 2021 at 12:44:58PM -0400, Patrick Palka wrote:
> > Ah yeah, sorry for the noise, I misunderstood the function comment.
> >
> > On a related note I think 'ctx' can also be a NAMESPACE_DECL here in
> > the case of a defaulted non-member operator<=> (as in the below), for
> > which I'd expect the added COMPLETE_TYPE_P check to crash, but it looks
> > like in this case DECL_INITIAL is error_mark_node instead of NULL_TREE
> > so a crash is averted. If anyone else was wondering...
> >
> > struct A {
> > friend constexpr bool operator==(const A&, const A&);
> > };
> >
> > constexpr bool operator==(const A&, const A&) = default;
>
> That means maybe ctx isn't the right way to get at the type and we
> should look it up from the first argument's type?
> I guess I'll look at where the build_comparison_op takes it from...
tree lhs = DECL_ARGUMENTS (fndecl);
if (is_this_parameter (lhs))
lhs = cp_build_fold_indirect_ref (lhs);
else
lhs = convert_from_reference (lhs);
tree ctype = TYPE_MAIN_VARIANT (TREE_TYPE (lhs));
apparently.
Jakub