public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [pushed] c++: Fix member alias template in C++17 and up. [PR96805]
Date: Thu,  8 Oct 2020 16:54:06 -0400	[thread overview]
Message-ID: <20201008205406.2220-1-jason@redhat.com> (raw)

Here we're trying to push into a<T>::c<N> in order to instantiate t<N>, but
were building a TYPENAME_TYPE for it because a<T> isn't open yet.  Don't
do that when we know we're trying to enter the scope.

Tested x86_64-pc-linux-gnu, applying to trunk and 10.

gcc/cp/ChangeLog:

	PR c++/96805
	PR c++/96199
	* pt.c (tsubst_aggr_type): Don't build a TYPENAME_TYPE when
	entering_scope.
	(tsubst_template_decl): Use tsubst_aggr_type.

gcc/testsuite/ChangeLog:

	PR c++/96805
	* g++.dg/cpp0x/alias-decl-pr96805.C: New test.
---
 gcc/cp/pt.c                                     | 9 +++++++--
 gcc/testsuite/g++.dg/cpp0x/alias-decl-pr96805.C | 9 +++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-pr96805.C

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 9a83810b67c..555dc47b464 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -13451,7 +13451,8 @@ tsubst_aggr_type (tree t,
 					 complain, in_decl);
 	  if (argvec == error_mark_node)
 	    r = error_mark_node;
-	  else if (cxx_dialect >= cxx17 && dependent_scope_p (context))
+	  else if (!entering_scope
+		   && cxx_dialect >= cxx17 && dependent_scope_p (context))
 	    {
 	      /* See maybe_dependent_member_ref.  */
 	      tree name = TYPE_IDENTIFIER (t);
@@ -14160,7 +14161,11 @@ tsubst_template_decl (tree t, tree args, tsubst_flags_t complain,
 	  class_p = true;
 	  inner = TREE_TYPE (inner);
 	}
-      inner = tsubst (inner, args, complain, in_decl);
+      if (class_p)
+	inner = tsubst_aggr_type (inner, args, complain,
+				  in_decl, /*entering*/1);
+      else
+	inner = tsubst (inner, args, complain, in_decl);
     }
   --processing_template_decl;
   if (inner == error_mark_node)
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-pr96805.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-pr96805.C
new file mode 100644
index 00000000000..c784f273441
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-pr96805.C
@@ -0,0 +1,9 @@
+// PR c++/96805
+// { dg-do compile { target c++11 } }
+
+template <typename T> class a {
+  template <int N> struct c {
+    template <bool B> using t = int;
+    t<N> m;
+  };
+};

base-commit: a500588aa523f1f04ae51809e476e3ebfcb081d3
-- 
2.18.1


                 reply	other threads:[~2020-10-08 20:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201008205406.2220-1-jason@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).