public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-7044] c++: Member fns and deduction guide rewriting [PR98929]
@ 2021-02-02 17:12 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2021-02-02 17:12 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:709718d4d89e5976257f53e67dcb8ba704574c56

commit r11-7044-g709718d4d89e5976257f53e67dcb8ba704574c56
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Feb 2 10:08:48 2021 -0500

    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.

Diff:
---
 gcc/cp/error.c                                         |  3 ++-
 gcc/cp/pt.c                                            | 10 ++++++++++
 gcc/testsuite/g++.dg/cpp1z/class-deduction-decltype1.C | 11 +++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 60f4fd691f3..5213a8030ca 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -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)))
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index db0ff73bdeb..aa1687a9f2a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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;
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction-decltype1.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction-decltype1.C
new file mode 100644
index 00000000000..b83f7adecc7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction-decltype1.C
@@ -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 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-02-02 17:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-02 17:12 [gcc r11-7044] c++: Member fns and deduction guide rewriting [PR98929] Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).