]> granicus.if.org Git - clang/commitdiff
Diagnose the declaration of template template parameters that
authorDouglas Gregor <dgregor@apple.com>
Thu, 21 Oct 2010 17:26:49 +0000 (17:26 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 21 Oct 2010 17:26:49 +0000 (17:26 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117032 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Parse/ParseTemplate.cpp
lib/Sema/SemaTemplate.cpp
test/CXX/temp/temp.param/p1.cpp

index 87d2a9f81f8b22f4ee9e3aabd137f238bee8cd38..17a585896b1273a995fe7a55b6216ff276783047 100644 (file)
@@ -1386,6 +1386,8 @@ def err_template_parameter_default_template_member : Error<
   "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<
index 8142cd226b5c92e18d1c8270b1fbb68b2021817a..c472972e5cb10e16e96bddd5606981344033c194 100644 (file)
@@ -540,7 +540,7 @@ Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) {
   TemplateParamsTy *ParamList =
     Actions.ActOnTemplateParameterList(Depth, SourceLocation(),
                                        TemplateLoc, LAngleLoc,
-                                       &TemplateParams[0],
+                                       TemplateParams.data(),
                                        TemplateParams.size(),
                                        RAngleLoc);
 
index cd67955a22ace75e889b20edb8c7b5c5d0453dc2..95b2223658cd52c17e3d30c3a185a6893145a822 100644 (file)
@@ -666,7 +666,7 @@ Decl *Sema::ActOnTemplateTemplateParameter(Scope* S,
     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 @@ Decl *Sema::ActOnTemplateTemplateParameter(Scope* S,
     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;
 }
 
index 676bffe31dc5065c3c5c7dc9910727e8a2091b25..edc99733f089520e6030bbf05d1fa84a087b0126 100644 (file)
@@ -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.