From 474e0129ac2e906caa667eb7a9a7682afeec41aa Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Mon, 2 May 2016 18:36:40 +0000 Subject: [PATCH] PR c++/62314: add fixit hint for missing "template <> " in explicit specialization gcc/cp/ChangeLog: PR c++/62314 * parser.c (cp_parser_class_head): Capture the start location; use it to emit a fix-it insertion hint when complaining about missing "template <> " in explicit specializations. gcc/testsuite/ChangeLog: PR c++/62314 * g++.dg/pr62314.C: New test case. From-SVN: r235777 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/parser.c | 18 ++++++++++++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/pr62314.C | 17 +++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pr62314.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c40efcfc2cf..18292e2a792 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2016-05-02 David Malcolm + + PR c++/62314 + * parser.c (cp_parser_class_head): Capture the start location; + use it to emit a fix-it insertion hint when complaining + about missing "template <> " in explicit specializations. + 2016-05-02 Richard Sandiford * init.c (build_new_1): Use shift operators instead of wi:: shifts. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index ded0dee6b5f..667ed97cbec 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 %