Index: include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -5831,6 +5831,8 @@ def err_expected_class_or_namespace : Error<"%0 is not a class" "%select{ or namespace|, namespace, or enumeration}1">; +def err_missing_argument_list : Error<"missing template argument list for " + "class template %0">; def err_invalid_declarator_scope : Error<"cannot define or redeclare %0 here " "because namespace %1 does not enclose namespace %2">; def err_invalid_declarator_global_scope : Error< Index: lib/Sema/SemaCXXScopeSpec.cpp =================================================================== --- lib/Sema/SemaCXXScopeSpec.cpp +++ lib/Sema/SemaCXXScopeSpec.cpp @@ -771,9 +771,29 @@ } if (!Found.empty()) { - if (TypeDecl *TD = Found.getAsSingle()) + if (ClassTemplateDecl *CTD = Found.getAsSingle()) { + TemplateParameterList *TPL = CTD->getTemplateParameters(); + assert(TPL && "NULL template parameter list"); + std::string FixString = Identifier.getName(); + FixString += "<"; + bool FirstArg = true; + for (NamedDecl *TemplArg : *TPL) { + if (FirstArg) + FirstArg = false; + else + FixString += ", "; + FixString += TemplArg->getName(); + } + FixString += ">"; + Diag(IdentifierLoc, diag::err_missing_argument_list) << &Identifier + << FixItHint::CreateReplacement(IdentifierLoc, FixString); + if (NamedDecl *ND = Found.getAsSingle()) + Diag(ND->getLocation(), diag::note_entity_declared_at) << &Identifier; + } + else if (TypeDecl *TD = Found.getAsSingle()) { Diag(IdentifierLoc, diag::err_expected_class_or_namespace) << QualType(TD->getTypeForDecl(), 0) << getLangOpts().CPlusPlus; + } else { Diag(IdentifierLoc, diag::err_expected_class_or_namespace) << &Identifier << getLangOpts().CPlusPlus; Index: test/SemaTemplate/temp_arg_lookup.cpp =================================================================== --- test/SemaTemplate/temp_arg_lookup.cpp +++ test/SemaTemplate/temp_arg_lookup.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +template +class X { // expected-note{{declared here}} + T foo(void); +}; + +template +T X::foo(void) // expected-error{{missing template argument list for class template}}} +{ + return 0; +}