c++: ->template and using-decl [PR104235]

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.
This commit is contained in:
Jason Merrill 2022-01-26 10:40:42 -05:00
parent 1bc00a4890
commit 00d8321124
2 changed files with 10 additions and 1 deletions

View 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;
}

View File

@ -0,0 +1,8 @@
// PR c++/104235
template <class M>
struct L: M {
using M::a;
void a();
void p() { this->template a<>(); }
};