Improve & simplify diagnostic for missing 'class' in template template parameter.
Change suggested by Sebastian Redl on review feedback from r153887. llvm-svn: 154102
This commit is contained in:
parent
af3c79f0ac
commit
3a7efa2240
|
@ -479,8 +479,8 @@ def err_unknown_template_name : Error<
|
||||||
"unknown template name %0">;
|
"unknown template name %0">;
|
||||||
def err_expected_comma_greater : Error<
|
def err_expected_comma_greater : Error<
|
||||||
"expected ',' or '>' in template-parameter-list">;
|
"expected ',' or '>' in template-parameter-list">;
|
||||||
def err_expected_class_before : Error<"expected 'class' before '%0'">;
|
def err_expected_class_on_template_template_param : Error<
|
||||||
def err_expected_class_instead : Error<"expected 'class' instead of '%0'">;
|
"template template parameters require 'class' after the argument list">;
|
||||||
def err_template_spec_syntax_non_template : Error<
|
def err_template_spec_syntax_non_template : Error<
|
||||||
"identifier followed by '<' indicates a class template specialization but "
|
"identifier followed by '<' indicates a class template specialization but "
|
||||||
"%0 %select{does not refer to a template|refers to a function "
|
"%0 %select{does not refer to a template|refers to a function "
|
||||||
|
|
|
@ -541,14 +541,12 @@ Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) {
|
||||||
// Generate a meaningful error if the user forgot to put class before the
|
// Generate a meaningful error if the user forgot to put class before the
|
||||||
// identifier, comma, or greater.
|
// identifier, comma, or greater.
|
||||||
if (Tok.is(tok::kw_typename) || Tok.is(tok::kw_struct)) {
|
if (Tok.is(tok::kw_typename) || Tok.is(tok::kw_struct)) {
|
||||||
Diag(Tok.getLocation(), diag::err_expected_class_instead)
|
Diag(Tok.getLocation(), diag::err_expected_class_on_template_template_param)
|
||||||
<< PP.getSpelling(Tok)
|
|
||||||
<< FixItHint::CreateReplacement(Tok.getLocation(), "class");
|
<< FixItHint::CreateReplacement(Tok.getLocation(), "class");
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
} else if (!Tok.is(tok::kw_class))
|
} else if (!Tok.is(tok::kw_class))
|
||||||
Diag(Tok.getLocation(), diag::err_expected_class_before)
|
Diag(Tok.getLocation(), diag::err_expected_class_on_template_template_param)
|
||||||
<< PP.getSpelling(Tok)
|
<< FixItHint::CreateInsertion(Tok.getLocation(), "class ");
|
||||||
<< FixItHint::CreateInsertion(Tok.getLocation(), "class ");
|
|
||||||
else
|
else
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,7 @@ template<class T> typedef Mystery<T>::type getMysteriousThing() { // \
|
||||||
return Mystery<T>::get();
|
return Mystery<T>::get();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<template<typename> Foo, // expected-error {{expected 'class' before 'Foo'}}
|
template<template<typename> Foo, // expected-error {{template template parameters require 'class' after the argument list}}
|
||||||
template<typename> typename Bar, // expected-error {{expected 'class' instead of 'typename'}}
|
template<typename> typename Bar, // expected-error {{template template parameters require 'class' after the argument list}}
|
||||||
template<typename> struct Baz> // expected-error {{expected 'class' instead of 'struct'}}
|
template<typename> struct Baz> // expected-error {{template template parameters require 'class' after the argument list}}
|
||||||
void func();
|
void func();
|
||||||
|
|
|
@ -11,8 +11,8 @@ template < ; // expected-error {{parse error}} \
|
||||||
// expected-warning {{declaration does not declare anything}}
|
// expected-warning {{declaration does not declare anything}}
|
||||||
template <template X> struct Err1; // expected-error {{expected '<' after 'template'}} \
|
template <template X> struct Err1; // expected-error {{expected '<' after 'template'}} \
|
||||||
// expected-error{{extraneous}}
|
// expected-error{{extraneous}}
|
||||||
template <template <typename> > struct Err2; // expected-error {{expected 'class' before '>'}}
|
template <template <typename> > struct Err2; // expected-error {{template template parameters require 'class' after the argument list}}
|
||||||
template <template <typename> Foo> struct Err3; // expected-error {{expected 'class' before 'Foo'}}
|
template <template <typename> Foo> struct Err3; // expected-error {{template template parameters require 'class' after the argument list}}
|
||||||
|
|
||||||
// Template function declarations
|
// Template function declarations
|
||||||
template <typename T> void foo();
|
template <typename T> void foo();
|
||||||
|
|
Loading…
Reference in New Issue