From: Jason Merrill Date: Wed, 28 Feb 2018 21:34:56 +0000 (-0500) Subject: PR c++/71784 - ICE with ref-qualifier and explicit specialization. X-Git-Tag: releases/gcc-6.5.0~495 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f0f8c372556275df873e859bb114a611505d01b;p=thirdparty%2Fgcc.git PR c++/71784 - ICE with ref-qualifier and explicit specialization. * pt.c (determine_specialization): Check ref-qualifier. From-SVN: r258087 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 387740d61046..d30784fbf156 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-02-28 Jason Merrill + + PR c++/71784 - ICE with ref-qualifier and explicit specialization. + * pt.c (determine_specialization): Check ref-qualifier. + 2018-02-26 Jason Merrill PR c++/84441 - ICE with base initialized from ?: diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 28bb78531981..9dbf17ba4d88 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2170,10 +2170,17 @@ determine_specialization (tree template_id, that the const qualification is the same. Since get_bindings does not try to merge the "this" parameter, we must do the comparison explicitly. */ - if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fn) - && !same_type_p (TREE_VALUE (fn_arg_types), - TREE_VALUE (decl_arg_types))) - continue; + if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fn)) + { + if (!same_type_p (TREE_VALUE (fn_arg_types), + TREE_VALUE (decl_arg_types))) + continue; + + /* And the ref-qualification. */ + if (type_memfn_rqual (TREE_TYPE (decl)) + != type_memfn_rqual (TREE_TYPE (fn))) + continue; + } /* Skip the "this" parameter and, for constructors of classes with virtual bases, the VTT parameter. A @@ -2279,6 +2286,11 @@ determine_specialization (tree template_id, decl_arg_types)) continue; + if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fn) + && (type_memfn_rqual (TREE_TYPE (decl)) + != type_memfn_rqual (TREE_TYPE (fn)))) + continue; + // If the deduced arguments do not satisfy the constraints, // this is not a candidate. if (flag_concepts && !constraints_satisfied_p (fn)) diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual18.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual18.C new file mode 100644 index 000000000000..aaa00b9cfc3d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/ref-qual18.C @@ -0,0 +1,18 @@ +// PR c++/71784 +// { dg-do compile { target c++11 } } + +template struct A { + template void f(U const&) & { } + template void f(U const&) && { } +}; + +template void A::f(int const&) &; +template void A::f(int const&) &&; + +template struct B { + void f(int const&) & { } + void f(int const&) && { } +}; + +template void B::f(int const&) &; +template void B::f(int const&) &&;