c++: ->template and using-decl [PR104235]
authorJason Merrill <jason@redhat.com>
Wed, 26 Jan 2022 15:40:42 +0000 (10:40 -0500)
committerJason Merrill <jason@redhat.com>
Wed, 26 Jan 2022 16:39:40 +0000 (11:39 -0500)
cp_parser_template_id wasn't prepared to handle getting a USING_DECL back
from cp_parser_template_name.  Let's defer that case to instantiation time,
as well.

PR c++/104235

gcc/cp/ChangeLog:

* parser.cc (cp_parser_template_name): Repeat lookup of USING_DECL.

gcc/testsuite/ChangeLog:

* g++.dg/parse/template-keyword2.C: New test.

gcc/cp/parser.cc
gcc/testsuite/g++.dg/parse/template-keyword2.C [new file with mode: 0644]

index ed219d7..8b38165 100644 (file)
@@ -18680,7 +18680,8 @@ cp_parser_template_name (cp_parser* parser,
          cp_parser_error (parser, "expected template-name");
          return error_mark_node;
        }
-      else if (!DECL_P (decl) && !is_overloaded_fn (decl))
+      else if ((!DECL_P (decl) && !is_overloaded_fn (decl))
+              || TREE_CODE (decl) == USING_DECL)
        /* Repeat the lookup at instantiation time.  */
        decl = identifier;
     }
diff --git a/gcc/testsuite/g++.dg/parse/template-keyword2.C b/gcc/testsuite/g++.dg/parse/template-keyword2.C
new file mode 100644 (file)
index 0000000..ecd0667
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/104235
+
+template <class M>
+struct L: M {
+  using M::a;
+  void a();
+  void p() { this->template a<>(); }
+};