// Find any previous declaration with this name.
DeclContext *SemanticContext;
- LookupResult Previous(*this, Name, NameLoc, LookupOrdinaryName,
+ LookupResult Previous(*this, Name, NameLoc, LookupTagName,
ForRedeclaration);
if (SS.isNotEmpty() && !SS.isInvalid()) {
SemanticContext = computeDeclContext(SS, true);
while (!OutermostContext->isFileContext())
OutermostContext = OutermostContext->getLookupParent();
- if (PrevClassTemplate &&
+ if (PrevDecl &&
(OutermostContext->Equals(PrevDecl->getDeclContext()) ||
OutermostContext->Encloses(PrevDecl->getDeclContext()))) {
SemanticContext = PrevDecl->getDeclContext();
}
}
- if (CurContext->isDependentContext()) {
+ if (CurContext->isDependentContext() && PrevClassTemplate) {
// If this is a dependent context, we don't want to link the friend
// class template to the template in scope, because that would perform
// checking of the template parameter lists that can't be performed
A<double>::B<double> ab;
}
+
+namespace RedeclUnrelated {
+ struct S {
+ int packaged_task;
+ template<typename> class future {
+ template<typename> friend class packaged_task;
+ };
+ future<void> share;
+ };
+}
+
+namespace PR12557 {
+ template <typename>
+ struct Foo;
+
+ template <typename Foo_>
+ struct Bar {
+ typedef Foo_ Foo; // expected-note {{previous}}
+
+ template <typename> friend struct Foo; // expected-error {{redefinition of 'Foo' as different kind of symbol}}
+ };
+
+ Bar<int> b;
+}