2017-06-28 Jason Merrill <jason@redhat.com>
+ PR c++/55639 - partial specialization with ::template
+ * parser.c (cp_parser_class_head): Handle ::template.
+
PR c++/45976 - error with ::template in declarator.
* pt.c (resolve_typename_type): Fix TEMPLATE_ID_EXPR handling.
/*is_declaration=*/false);
/* If there was a nested-name-specifier, then there *must* be an
identifier. */
+
+ cp_token *bad_template_keyword = NULL;
+
if (nested_name_specifier)
{
type_start_token = cp_lexer_peek_token (parser->lexer);
class-name is a template-id; if we looked for the
template-name first we would stop after the template-name. */
cp_parser_parse_tentatively (parser);
+ if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TEMPLATE))
+ bad_template_keyword = cp_lexer_consume_token (parser->lexer);
type = cp_parser_class_name (parser,
/*typename_keyword_p=*/false,
/*template_keyword_p=*/false,
{
tree scope;
+ if (bad_template_keyword)
+ /* [temp.names]: in a qualified-id formed by a class-head-name, the
+ keyword template shall not appear at the top level. */
+ pedwarn (bad_template_keyword->location, OPT_Wpedantic,
+ "keyword %<template%> not allowed in class-head-name");
+
/* Reject typedef-names in class heads. */
if (!DECL_IMPLICIT_TYPEDEF_P (type))
{