c++: Member fns and deduction guide rewriting [PR98929]

My patch for 96199 had us re-substitute the parameter types of a constructor
in order to rewrite mentions of members into dependent references.  We need
to do that for member functions, too.

gcc/cp/ChangeLog:

	PR c++/98929
	PR c++/96199
	* error.c (dump_expr): Ignore dummy object.
	* pt.c (tsubst_baselink): Handle dependent scope.

gcc/testsuite/ChangeLog:

	PR c++/98929
	* g++.dg/cpp1z/class-deduction-decltype1.C: New test.
This commit is contained in:
Jason Merrill 2021-02-02 10:08:48 -05:00
parent d14cf89b94
commit 709718d4d8
3 changed files with 23 additions and 1 deletions

View file

@ -2352,7 +2352,8 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
if (INDIRECT_REF_P (ob))
{
ob = TREE_OPERAND (ob, 0);
if (!is_this_parameter (ob))
if (!is_this_parameter (ob)
&& !is_dummy_object (ob))
{
dump_expr (pp, ob, flags | TFF_EXPR_IN_PARENS);
if (TYPE_REF_P (TREE_TYPE (ob)))

View file

@ -16196,6 +16196,16 @@ tsubst_baselink (tree baselink, tree object_type,
if (IDENTIFIER_CONV_OP_P (name))
name = make_conv_op_name (optype);
/* See maybe_dependent_member_ref. */
if (dependent_scope_p (qualifying_scope))
{
if (template_id_p)
name = build2 (TEMPLATE_ID_EXPR, unknown_type_node, name,
template_args);
return build_qualified_name (NULL_TREE, qualifying_scope, name,
/* ::template */false);
}
if (name == complete_dtor_identifier)
/* Treat as-if non-dependent below. */
dependent_p = false;

View file

@ -0,0 +1,11 @@
// PR c++/98929
// { dg-do compile { target c++17 } }
template <typename T>
struct A {
void foo ();
using c = decltype (foo ());
A (c); // { dg-message {decltype \(A<T>::foo} }
};
A d; // { dg-error "deduction failed" }
// { dg-error "no match" "" { target *-*-* } .-1 }