On 2026-05-25 18:58:09, Eczbek wrote:
> Bootstrapped/regtested on x86_64-pc-linux-gnu 

While I'm still waiting for copyright assignment, can this small patch be 
accepted in the meanwhile?

-- >8 --
 
> When forming a member function pointer type to a ref-qualified function
> type, the reference qualifier is incorrectly dropped.
> 
>       PR c++/70097
> 
> gcc/cp/ChangeLog:
> 
>       * decl.cc (grokdeclarator): If rqual is REF_QUAL_NONE, set it to
>       result of type_memfn_rqual before passing to build_memfn_type.
> 
> gcc/testsuite/ChangeLog:
> 
>       * g++.dg/cpp0x/ref-qual22.C: New test.
> ---
>  gcc/cp/decl.cc                          |  2 ++
>  gcc/testsuite/g++.dg/cpp0x/ref-qual22.C | 18 ++++++++++++++++++
>  2 files changed, 20 insertions(+)
>  create mode 100644 gcc/testsuite/g++.dg/cpp0x/ref-qual22.C
> 
> diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
> index f0f37560dec..546602f143f 100644
> --- a/gcc/cp/decl.cc
> +++ b/gcc/cp/decl.cc
> @@ -15669,6 +15669,8 @@ grokdeclarator (const cp_declarator *declarator,
>             && TREE_CODE (type) == FUNCTION_TYPE)
>           {
>             memfn_quals |= type_memfn_quals (type);
> +           if (rqual == REF_QUAL_NONE)
> +               rqual = type_memfn_rqual (type);
>             type = build_memfn_type (type,
>                                      declarator->u.pointer.class_type,
>                                      memfn_quals,
> diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual22.C 
> b/gcc/testsuite/g++.dg/cpp0x/ref-qual22.C
> new file mode 100644
> index 00000000000..4859d20053b
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp0x/ref-qual22.C
> @@ -0,0 +1,18 @@
> +// PR c++/70097
> +// { dg-do compile { target c++11 } }
> +
> +struct T {
> +     void f() & {}
> +     void g() && {}
> +};
> +using F = void() &;
> +using G = void() &&;
> +
> +F T::* f = &T::f;
> +G T::* g = &T::g;
> +
> +template<typename> struct U;
> +template<> struct U<void(T::*)() &> {};
> +template<> struct U<void(T::*)() &&> {};
> +U<F T::*> u;
> +U<G T::*> v;
> 
> base-commit: b1987874feead5e98f1ea005bd1ce5ff515eda7a


Reply via email to