Skip to content
Snippets Groups Projects
Commit b7f71961 authored by Nathaniel Shead's avatar Nathaniel Shead
Browse files

c++: Improve fixits for incorrect explicit instantiations


When forgetting the '<>' on an explicit specialisation, the suggested
fixit hint suggests to add 'template <>', but naively applying will
cause nonsense results like 'template template <> struct S<int> {};'.

Instead check if we're currently parsing an explicit instantiation, and
if so inform about the issue (an instantiation cannot have a class body)
and suggest a fixit of simply '<>' to create a specialisation instead.

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_class_head): Clarify error message for
	explicit instantiations.

gcc/testsuite/ChangeLog:

	* g++.dg/template/explicit-instantiation9.C: New test.

Signed-off-by: default avatarNathaniel Shead <nathanieloshead@gmail.com>
parent 8fac69a2
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment