public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-6754] c++: template-id with current inst qualifier [PR102300]
@ 2022-01-20  3:42 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2022-01-20  3:42 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:30f2c22def7392119f1ffaca30ef998b3b43f336

commit r12-6754-g30f2c22def7392119f1ffaca30ef998b3b43f336
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Jan 18 18:28:22 2022 -0500

    c++: template-id with current inst qualifier [PR102300]
    
    The patch for PR41723 properly changed one place to look into the current
    instantiation; now we need to fix this place as well.
    
            PR c++/102300
    
    gcc/cp/ChangeLog:
    
            * parser.cc (cp_parser_template_name): Use dependent_scope_p.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/parse/no-typename1.C: Remove expected error.
            * g++.dg/template/nested7.C: New test.

Diff:
---
 gcc/cp/parser.cc                          |  8 ++++----
 gcc/testsuite/g++.dg/parse/no-typename1.C |  2 +-
 gcc/testsuite/g++.dg/template/nested7.C   | 12 ++++++++++++
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 00279c43404..ed219d79dc9 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -18574,7 +18574,7 @@ cp_parser_template_name (cp_parser* parser,
 			: parser->context->object_type);
 	  if (scope && TYPE_P (scope)
 	      && (!CLASS_TYPE_P (scope)
-		  || (check_dependency_p && dependent_type_p (scope))))
+		  || (check_dependency_p && dependent_scope_p (scope))))
 	    {
 	      /* We're optimizing away the call to cp_parser_lookup_name, but
 		 we still need to do this.  */
@@ -18667,9 +18667,9 @@ cp_parser_template_name (cp_parser* parser,
 	    found = true;
 	}
 
-      /* "in a type-only context" */
+      /* "that follows the keyword template"..."in a type-only context" */
       if (!found && scope
-	  && tag_type != none_type
+	  && (template_keyword_p || tag_type != none_type)
 	  && dependentish_scope_p (scope)
 	  && cp_parser_nth_token_starts_template_argument_list_p (parser, 1))
 	found = true;
@@ -18680,7 +18680,7 @@ cp_parser_template_name (cp_parser* parser,
 	  cp_parser_error (parser, "expected template-name");
 	  return error_mark_node;
 	}
-      else if (decl == error_mark_node)
+      else if (!DECL_P (decl) && !is_overloaded_fn (decl))
 	/* Repeat the lookup at instantiation time.  */
 	decl = identifier;
     }
diff --git a/gcc/testsuite/g++.dg/parse/no-typename1.C b/gcc/testsuite/g++.dg/parse/no-typename1.C
index 711c621e26a..f40ea0ec13c 100644
--- a/gcc/testsuite/g++.dg/parse/no-typename1.C
+++ b/gcc/testsuite/g++.dg/parse/no-typename1.C
@@ -6,6 +6,6 @@ template <typename T> struct A
 {
     template <typename U> struct B
     {
-        A<T>::template B<U> foo(); // { dg-error "" "" { target c++17_down } }
+        A<T>::template B<U> foo();
     };
 };
diff --git a/gcc/testsuite/g++.dg/template/nested7.C b/gcc/testsuite/g++.dg/template/nested7.C
new file mode 100644
index 00000000000..3a5930c0f31
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/nested7.C
@@ -0,0 +1,12 @@
+// PR c++/102300
+
+template<typename T>
+struct holder
+{
+  template<typename F> struct fn {};
+
+  struct t1 : fn<T> {};                      // pass
+  struct t2 : holder<T >::fn<T> {};          // fail
+  struct t3 : holder<T >::template fn<T> {}; // fail
+  struct t4 : holder<T*>::template fn<T> {}; // pass
+};


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

only message in thread, other threads:[~2022-01-20  3:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-20  3:42 [gcc r12-6754] c++: template-id with current inst qualifier [PR102300] 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).