[cfe-commits] r117032 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Parse/ParseTemplate.cpp lib/Sema/SemaTemplate.cpp test/CXX/temp/temp.param/p1.cpp
Douglas Gregor
dgregor at apple.com
Thu Oct 21 10:26:49 PDT 2010
Author: dgregor
Date: Thu Oct 21 12:26:49 2010
New Revision: 117032
URL: http://llvm.org/viewvc/llvm-project?rev=117032&view=rev
Log:
Diagnose the declaration of template template parameters that
themselves have no template parameters. This is actually a restriction
due to the grammar of template template parameters, but we choose to
diagnose it in Sema to provide better recovery.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CXX/temp/temp.param/p1.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=117032&r1=117031&r2=117032&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Oct 21 12:26:49 2010
@@ -1386,6 +1386,8 @@
"class template">;
def err_template_parameter_default_friend_template : Error<
"default template argument not permitted on a friend template">;
+def err_template_template_parm_no_parms : Error<
+ "template template parameter must have its own template parameters">;
def err_template_variable : Error<"variable %0 declared as a template">;
def err_template_variable_noparams : Error<
Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=117032&r1=117031&r2=117032&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Thu Oct 21 12:26:49 2010
@@ -540,7 +540,7 @@
TemplateParamsTy *ParamList =
Actions.ActOnTemplateParameterList(Depth, SourceLocation(),
TemplateLoc, LAngleLoc,
- &TemplateParams[0],
+ TemplateParams.data(),
TemplateParams.size(),
RAngleLoc);
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=117032&r1=117031&r2=117032&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Oct 21 12:26:49 2010
@@ -666,7 +666,7 @@
TemplateTemplateParmDecl::Create(Context, Context.getTranslationUnitDecl(),
NameLoc.isInvalid()? TmpLoc : NameLoc,
Depth, Position, Name,
- (TemplateParameterList*)Params);
+ Params);
// If the template template parameter has a name, then link the identifier
// into the scope and lookup mechanisms.
@@ -694,6 +694,11 @@
Param->setDefaultArgument(DefaultArg, false);
}
+ if (Params->size() == 0) {
+ Diag(Param->getLocation(), diag::err_template_template_parm_no_parms)
+ << SourceRange(Params->getLAngleLoc(), Params->getRAngleLoc());
+ Param->setInvalidDecl();
+ }
return Param;
}
Modified: cfe/trunk/test/CXX/temp/temp.param/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.param/p1.cpp?rev=117032&r1=117031&r2=117032&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.param/p1.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.param/p1.cpp Thu Oct 21 12:26:49 2010
@@ -1,4 +1,6 @@
// Suppress 'no run line' failure.
-// RUN: echo ok
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<template<> class C> class D; // expected-error{{template template parameter must have its own template parameters}}
+
-// Paragraph 1 is descriptive, and therefore requires no tests.
More information about the cfe-commits
mailing list