diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | clang/lib/Parse/ParseTemplate.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 7 | ||||
-rw-r--r-- | clang/test/CXX/temp/temp.param/p1.cpp | 6 |
4 files changed, 13 insertions, 4 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 87d2a9f81f8..17a585896b1 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/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/clang/lib/Parse/ParseTemplate.cpp b/clang/lib/Parse/ParseTemplate.cpp index 8142cd226b5..c472972e5cb 100644 --- a/clang/lib/Parse/ParseTemplate.cpp +++ b/clang/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/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index cd67955a22a..95b2223658c 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/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/clang/test/CXX/temp/temp.param/p1.cpp b/clang/test/CXX/temp/temp.param/p1.cpp index 676bffe31dc..edc99733f08 100644 --- a/clang/test/CXX/temp/temp.param/p1.cpp +++ b/clang/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. |