diff options
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | lib/Parse/ParseTemplate.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 7 | ||||
-rw-r--r-- | test/CXX/temp/temp.param/p1.cpp | 6 |
4 files changed, 13 insertions, 4 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 87d2a9f81f..17a585896b 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -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< diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp index 8142cd226b..c472972e5c 100644 --- a/lib/Parse/ParseTemplate.cpp +++ b/lib/Parse/ParseTemplate.cpp @@ -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); diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index cd67955a22..95b2223658 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -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; } diff --git a/test/CXX/temp/temp.param/p1.cpp b/test/CXX/temp/temp.param/p1.cpp index 676bffe31d..edc99733f0 100644 --- a/test/CXX/temp/temp.param/p1.cpp +++ b/test/CXX/temp/temp.param/p1.cpp @@ -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. |