diff options
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r-- | gcc/cp/parser.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index ded0dee..667ed97 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -21656,6 +21656,8 @@ cp_parser_class_head (cp_parser* parser, if (class_key == none_type) return error_mark_node; + location_t class_head_start_location = input_location; + /* Parse the attributes. */ attributes = cp_parser_attributes_opt (parser); @@ -21872,8 +21874,20 @@ cp_parser_class_head (cp_parser* parser, && parser->num_template_parameter_lists == 0 && template_id_p) { - error_at (type_start_token->location, - "an explicit specialization must be preceded by %<template <>%>"); + /* Build a location of this form: + struct typename <ARGS> + ^~~~~~~~~~~~~~~~~~~~~~ + with caret==start at the start token, and + finishing at the end of the type. */ + location_t reported_loc + = make_location (class_head_start_location, + class_head_start_location, + get_finish (type_start_token->location)); + rich_location richloc (line_table, reported_loc); + richloc.add_fixit_insert (class_head_start_location, "template <> "); + error_at_rich_loc + (&richloc, + "an explicit specialization must be preceded by %<template <>%>"); invalid_explicit_specialization_p = true; /* Take the same action that would have been taken by cp_parser_explicit_specialization. */ |