Replace r155185 with a better fix, which also addresses PR12557. When looking
up an elaborated type specifier in a friend declaration, only look for type
declarations, per [basic.lookup.elab]p2. If we know that the redeclaration
lookup for a friend class template in a dependent context finds a non-template,
don't delay the diagnostic to instantiation time.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155187 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaTemplate/friend-template.cpp b/test/SemaTemplate/friend-template.cpp
index 9c95fa0..2b05527 100644
--- a/test/SemaTemplate/friend-template.cpp
+++ b/test/SemaTemplate/friend-template.cpp
@@ -243,3 +243,27 @@
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;
+}