public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-6896] c++: constrained partial spec using qualified name [PR92944, PR103678]
@ 2022-01-27 16:02 Patrick Palka
  0 siblings, 0 replies; only message in thread
From: Patrick Palka @ 2022-01-27 16:02 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:ce6054a22ae14594a2919d2ad87cd9478e616fb3

commit r12-6896-gce6054a22ae14594a2919d2ad87cd9478e616fb3
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Jan 27 10:56:34 2022 -0500

    c++: constrained partial spec using qualified name [PR92944, PR103678]
    
    In the nested_name_specifier branch within cp_parser_class_head, we need
    to update 'type' with the result of maybe_process_partial_specialization
    like we do in the template_id_p branch.
    
            PR c++/92944
            PR c++/103678
    
    gcc/cp/ChangeLog:
    
            * parser.cc (cp_parser_class_head): Update 'type' with the result
            of maybe_process_partial_specialization in the
            nested_name_specifier branch.  Refactor nearby code to accomodate
            that maybe_process_partial_specialization returns a _TYPE, not a
            TYPE_DECL, and eliminate local variable 'class_type' in passing.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp2a/concepts-partial-spec10.C: New test.
            * g++.dg/cpp2a/concepts-partial-spec11.C: New test.

Diff:
---
 gcc/cp/parser.cc                                     | 18 +++++++-----------
 gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec10.C | 17 +++++++++++++++++
 gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec11.C | 19 +++++++++++++++++++
 3 files changed, 43 insertions(+), 11 deletions(-)

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 8b38165020f..f1947ee3a1c 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -26535,7 +26535,7 @@ cp_parser_class_head (cp_parser* parser,
     }
   else if (nested_name_specifier)
     {
-      tree class_type;
+      type = TREE_TYPE (type);
 
       /* Given:
 
@@ -26545,31 +26545,27 @@ cp_parser_class_head (cp_parser* parser,
 	 we will get a TYPENAME_TYPE when processing the definition of
 	 `S::T'.  We need to resolve it to the actual type before we
 	 try to define it.  */
-      if (TREE_CODE (TREE_TYPE (type)) == TYPENAME_TYPE)
+      if (TREE_CODE (type) == TYPENAME_TYPE)
 	{
-	  class_type = resolve_typename_type (TREE_TYPE (type),
-					      /*only_current_p=*/false);
-	  if (TREE_CODE (class_type) != TYPENAME_TYPE)
-	    type = TYPE_NAME (class_type);
-	  else
+	  type = resolve_typename_type (type, /*only_current_p=*/false);
+	  if (TREE_CODE (type) == TYPENAME_TYPE)
 	    {
 	      cp_parser_error (parser, "could not resolve typename type");
 	      type = error_mark_node;
 	    }
 	}
 
-      if (maybe_process_partial_specialization (TREE_TYPE (type))
-	  == error_mark_node)
+      type = maybe_process_partial_specialization (type);
+      if (type == error_mark_node)
 	{
 	  type = NULL_TREE;
 	  goto done;
 	}
 
-      class_type = current_class_type;
       /* Enter the scope indicated by the nested-name-specifier.  */
       pushed_scope = push_scope (nested_name_specifier);
       /* Get the canonical version of this type.  */
-      type = TYPE_MAIN_DECL (TREE_TYPE (type));
+      type = TYPE_MAIN_DECL (type);
       /* Call push_template_decl if it seems like we should be defining a
 	 template either from the template headers or the type we're
 	 defining, so that we diagnose both extra and missing headers.  */
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec10.C b/gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec10.C
new file mode 100644
index 00000000000..d45a1b03e89
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec10.C
@@ -0,0 +1,17 @@
+// PR c++/92944
+// { dg-do compile { target c++20 } }
+
+namespace ns { template<class T> struct A { }; }
+
+template<class T> requires true struct ns::A<T> { using type = T; };
+template<class T> requires false struct ns::A<T> { };
+
+template<class T> struct ns::A<T*> { };
+template<class T> requires true struct ns::A<T*> { using type = T; };
+template<class T> requires false struct ns::A<T*> { };
+
+using ty1 = ns::A<int>::type;
+using ty1 = int;
+
+using ty2 = ns::A<int*>::type;
+using ty2 = int;
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec11.C b/gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec11.C
new file mode 100644
index 00000000000..03334500238
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec11.C
@@ -0,0 +1,19 @@
+// PR c++/103678
+// { dg-do compile { target c++20 } }
+
+template<class>
+struct A {
+ template<class...>
+ struct B;
+};
+
+template<class A_t>
+template<class B_t>
+struct A<A_t>::B<B_t> {};
+
+template<class A_t>
+template<class B_t>
+requires requires {
+ typename B_t;
+}
+struct A<A_t>::B<B_t> {};


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

only message in thread, other threads:[~2022-01-27 16:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-27 16:02 [gcc r12-6896] c++: constrained partial spec using qualified name [PR92944, PR103678] Patrick Palka

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).