[cfe-commits] r154102 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td lib/Parse/ParseTemplate.cpp test/FixIt/fixit.cpp test/Parser/cxx-template-decl.cpp
David Blaikie
dblaikie at gmail.com
Thu Apr 5 09:56:03 PDT 2012
Author: dblaikie
Date: Thu Apr 5 11:56:02 2012
New Revision: 154102
URL: http://llvm.org/viewvc/llvm-project?rev=154102&view=rev
Log:
Improve & simplify diagnostic for missing 'class' in template template parameter.
Change suggested by Sebastian Redl on review feedback from r153887.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/test/FixIt/fixit.cpp
cfe/trunk/test/Parser/cxx-template-decl.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=154102&r1=154101&r2=154102&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu Apr 5 11:56:02 2012
@@ -479,8 +479,8 @@
"unknown template name %0">;
def err_expected_comma_greater : Error<
"expected ',' or '>' in template-parameter-list">;
-def err_expected_class_before : Error<"expected 'class' before '%0'">;
-def err_expected_class_instead : Error<"expected 'class' instead of '%0'">;
+def err_expected_class_on_template_template_param : Error<
+ "template template parameters require 'class' after the argument list">;
def err_template_spec_syntax_non_template : Error<
"identifier followed by '<' indicates a class template specialization but "
"%0 %select{does not refer to a template|refers to a function "
Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=154102&r1=154101&r2=154102&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Thu Apr 5 11:56:02 2012
@@ -541,14 +541,12 @@
// Generate a meaningful error if the user forgot to put class before the
// identifier, comma, or greater.
if (Tok.is(tok::kw_typename) || Tok.is(tok::kw_struct)) {
- Diag(Tok.getLocation(), diag::err_expected_class_instead)
- << PP.getSpelling(Tok)
+ Diag(Tok.getLocation(), diag::err_expected_class_on_template_template_param)
<< FixItHint::CreateReplacement(Tok.getLocation(), "class");
ConsumeToken();
} else if (!Tok.is(tok::kw_class))
- Diag(Tok.getLocation(), diag::err_expected_class_before)
- << PP.getSpelling(Tok)
- << FixItHint::CreateInsertion(Tok.getLocation(), "class ");
+ Diag(Tok.getLocation(), diag::err_expected_class_on_template_template_param)
+ << FixItHint::CreateInsertion(Tok.getLocation(), "class ");
else
ConsumeToken();
Modified: cfe/trunk/test/FixIt/fixit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit.cpp?rev=154102&r1=154101&r2=154102&view=diff
==============================================================================
--- cfe/trunk/test/FixIt/fixit.cpp (original)
+++ cfe/trunk/test/FixIt/fixit.cpp Thu Apr 5 11:56:02 2012
@@ -200,7 +200,7 @@
return Mystery<T>::get();
}
-template<template<typename> Foo, // expected-error {{expected 'class' before 'Foo'}}
- template<typename> typename Bar, // expected-error {{expected 'class' instead of 'typename'}}
- template<typename> struct Baz> // expected-error {{expected 'class' instead of 'struct'}}
+template<template<typename> Foo, // expected-error {{template template parameters require 'class' after the argument list}}
+ template<typename> typename Bar, // expected-error {{template template parameters require 'class' after the argument list}}
+ template<typename> struct Baz> // expected-error {{template template parameters require 'class' after the argument list}}
void func();
Modified: cfe/trunk/test/Parser/cxx-template-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-template-decl.cpp?rev=154102&r1=154101&r2=154102&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-template-decl.cpp (original)
+++ cfe/trunk/test/Parser/cxx-template-decl.cpp Thu Apr 5 11:56:02 2012
@@ -11,8 +11,8 @@
// expected-warning {{declaration does not declare anything}}
template <template X> struct Err1; // expected-error {{expected '<' after 'template'}} \
// expected-error{{extraneous}}
-template <template <typename> > struct Err2; // expected-error {{expected 'class' before '>'}}
-template <template <typename> Foo> struct Err3; // expected-error {{expected 'class' before 'Foo'}}
+template <template <typename> > struct Err2; // expected-error {{template template parameters require 'class' after the argument list}}
+template <template <typename> Foo> struct Err3; // expected-error {{template template parameters require 'class' after the argument list}}
// Template function declarations
template <typename T> void foo();
More information about the cfe-commits
mailing list