static cp_expr cp_parser_unqualified_id
(cp_parser *, bool, bool, bool, bool);
static tree cp_parser_nested_name_specifier_opt
- (cp_parser *, bool, bool, bool, bool);
+ (cp_parser *, bool, bool, bool, bool, bool = false);
static tree cp_parser_nested_name_specifier
(cp_parser *, bool, bool, bool, bool);
static tree cp_parser_qualifying_entity
error_at (location_of (id),
"%qE in namespace %qE does not name a template type",
id, parser->scope);
+ else if (TREE_CODE (id) == TEMPLATE_ID_EXPR)
+ error_at (location_of (id),
+ "%qE in namespace %qE does not name a template type",
+ TREE_OPERAND (id, 0), parser->scope);
else
error_at (location_of (id),
"%qE in namespace %qE does not name a type",
error_at (location_of (id),
"%qE in %q#T does not name a template type",
id, parser->scope);
+ else if (TREE_CODE (id) == TEMPLATE_ID_EXPR)
+ error_at (location_of (id),
+ "%qE in %q#T does not name a template type",
+ TREE_OPERAND (id, 0), parser->scope);
else
error_at (location_of (id),
"%qE in %q#T does not name a type",
/* Look for the optional `::' operator. */
global_scope_p
- = (cp_parser_global_scope_opt (parser, /*current_scope_valid_p=*/false)
- != NULL_TREE);
+ = (!template_keyword_p
+ && (cp_parser_global_scope_opt (parser,
+ /*current_scope_valid_p=*/false)
+ != NULL_TREE));
+
/* Look for the optional nested-name-specifier. */
nested_name_specifier_p
= (cp_parser_nested_name_specifier_opt (parser,
/*typename_keyword_p=*/false,
check_dependency_p,
/*type_p=*/false,
- declarator_p)
+ declarator_p,
+ template_keyword_p)
!= NULL_TREE);
+
/* If there is a nested-name-specifier, then we are looking at
the first qualified-id production. */
if (nested_name_specifier_p)
bool typename_keyword_p,
bool check_dependency_p,
bool type_p,
- bool is_declaration)
+ bool is_declaration,
+ bool template_keyword_p /* = false */)
{
bool success = false;
cp_token_position start = 0;
tree new_scope;
tree old_scope;
tree saved_qualifying_scope;
- bool template_keyword_p;
/* Spot cases that cannot be the beginning of a
nested-name-specifier. */
first time through the loop. */
if (success)
template_keyword_p = cp_parser_optional_template_keyword (parser);
- else
- template_keyword_p = false;
/* Save the old scope since the name lookup we are about to do
might destroy it. */
no point in doing name-lookup, so we just return IDENTIFIER.
But, if the qualifying scope is non-dependent then we can
(and must) do name-lookup normally. */
- if (template_keyword_p
- && (!parser->scope
- || (TYPE_P (parser->scope)
- && dependent_type_p (parser->scope))))
+ if (template_keyword_p)
{
- /* We're optimizing away the call to cp_parser_lookup_name, but we
- still need to do this. */
- parser->context->object_type = NULL_TREE;
- return identifier;
+ tree scope = (parser->scope ? parser->scope
+ : parser->context->object_type);
+ if (scope && TYPE_P (scope)
+ && (!CLASS_TYPE_P (scope)
+ || (check_dependency_p && dependent_type_p (scope))))
+ {
+ /* We're optimizing away the call to cp_parser_lookup_name, but
+ we still need to do this. */
+ parser->context->object_type = NULL_TREE;
+ return identifier;
+ }
}
}
/*ambiguous_decls=*/NULL,
token->location);
+ /* If the lookup failed and we got the 'template' keyword, believe it. */
+ if (decl == error_mark_node && template_keyword_p
+ && processing_template_decl)
+ return identifier;
+
decl = strip_using_decl (decl);
/* If DECL is a template, then the name was a template-name. */