DIAG(err_template_recursion_depth_exceeded, ERROR,
"recursive template instantiation exceeded maximum depth of %0")
DIAG(note_template_recursion_depth, NOTE,
- "use -ftemplate-depth=N to increase recursive template "
+ "use -ftemplate-depth-N to increase recursive template "
"instantiation depth")
DIAG(err_template_implicit_instantiate_undefined, ERROR,
"implicit instantiation of undefined template %0")
InnerString = Name->getName() + InnerString;
}
-void
-ClassTemplateSpecializationType::
-getAsStringInternal(std::string &InnerString) const {
- std::string SpecString = Template->getNameAsString();
+/// \brief Print a template argument list, including the '<' and '>'
+/// enclosing the template arguments.
+static std::string printTemplateArgumentList(const TemplateArgument *Args,
+ unsigned NumArgs) {
+ std::string SpecString;
SpecString += '<';
for (unsigned Arg = 0; Arg < NumArgs; ++Arg) {
if (Arg)
// Print the argument into a string.
std::string ArgString;
- switch (getArg(Arg).getKind()) {
+ switch (Args[Arg].getKind()) {
case TemplateArgument::Type:
- getArg(Arg).getAsType().getAsStringInternal(ArgString);
+ Args[Arg].getAsType().getAsStringInternal(ArgString);
break;
case TemplateArgument::Declaration:
- ArgString = cast<NamedDecl>(getArg(Arg).getAsDecl())->getNameAsString();
+ ArgString = cast<NamedDecl>(Args[Arg].getAsDecl())->getNameAsString();
break;
case TemplateArgument::Integral:
- ArgString = getArg(Arg).getAsIntegral()->toString(10, true);
+ ArgString = Args[Arg].getAsIntegral()->toString(10, true);
break;
case TemplateArgument::Expression: {
llvm::raw_string_ostream s(ArgString);
- getArg(Arg).getAsExpr()->printPretty(s);
+ Args[Arg].getAsExpr()->printPretty(s);
break;
}
}
SpecString += '>';
+ return SpecString;
+}
+
+void
+ClassTemplateSpecializationType::
+getAsStringInternal(std::string &InnerString) const {
+ std::string SpecString = Template->getNameAsString();
+ SpecString += printTemplateArgumentList(getArgs(), getNumArgs());
if (InnerString.empty())
InnerString.swap(SpecString);
else
} else
ID = "<anonymous>";
+ // If this is a class template specialization, print the template
+ // arguments.
+ if (ClassTemplateSpecializationDecl *Spec
+ = dyn_cast<ClassTemplateSpecializationDecl>(getDecl())) {
+ std::string TemplateArgs
+ = printTemplateArgumentList(Spec->getTemplateArgs(),
+ Spec->getNumTemplateArgs());
+ InnerString = TemplateArgs + InnerString;
+ }
+
if (Kind)
InnerString = std::string(Kind) + " " + ID + InnerString;
else
if (Tag && Tag->getDecl()->getDeclContext()->isFunctionOrMethod())
return Diag(ArgLoc, diag::err_template_arg_local_type)
<< QualType(Tag, 0);
- else if (Tag && !Tag->getDecl()->getDeclName()) {
+ else if (Tag && !Tag->getDecl()->getDeclName() &&
+ !Tag->getDecl()->getTypedefForAnonDecl()) {
Diag(ArgLoc, diag::err_template_arg_unnamed_type);
Diag(Tag->getDecl()->getLocation(), diag::note_template_unnamed_type_here);
return true;
// RUN: clang -fsyntax-only -verify %s
-template<typename T> struct A; // expected-note{{template is declared here}}
+template<typename T> struct A; // expected-note 2{{template is declared here}}
-template<typename T> struct B : A<T*> { }; // expected-error{{implicit instantiation of undefined template}}
+template<typename T> struct B : A<T*> { }; // expected-error{{implicit instantiation of undefined template}} \
+// expected-error{{implicit instantiation of undefined template 'struct A<X *>'}}
template<typename T> struct C : B<T> { } ; // expected-note{{instantiation of template class}}
void f() {
(void)sizeof(F<int>); // expected-note{{instantiation of template class}}
}
+
+typedef struct { } X;
+
+void g() {
+ (void)sizeof(B<X>); // expected-note{{in instantiation of template class 'struct B<X>' requested here}}
+}