template-ids are looked up differently in friend declarations.
llvm-svn: 116529
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index a63f057..ee0b172 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -6384,6 +6384,7 @@
// declaration, if there is no prior declaration, the program is
// ill-formed.
bool isLocal = cast<CXXRecordDecl>(CurContext)->isLocalClass();
+ bool isTemplateId = D.getName().getKind() == UnqualifiedId::IK_TemplateId;
// Find the appropriate context according to the above.
DC = CurContext;
@@ -6404,7 +6405,11 @@
if (isLocal || !Previous.empty())
break;
- if (DC->isFileContext()) break;
+ if (isTemplateId) {
+ if (isa<TranslationUnitDecl>(DC)) break;
+ } else {
+ if (DC->isFileContext()) break;
+ }
DC = DC->getParent();
}