re PR c++/61327 (Problem with friend template object)
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 4 Apr 2019 15:38:05 +0000 (15:38 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 4 Apr 2019 15:38:05 +0000 (15:38 +0000)
2019-04-04  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/61327
* g++.dg/cpp0x/friend4.C: New.
* g++.dg/cpp0x/friend5.C: Likewise.

From-SVN: r270145

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/friend4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/friend5.C [new file with mode: 0644]

index 1195c4339eb53ebd624ec5d31a786612d10593c8..0363d1f0d89f82b738c2b73e86d20e179f141a64 100644 (file)
@@ -1,3 +1,9 @@
+2019-04-04  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/61327
+       * g++.dg/cpp0x/friend4.C: New.
+       * g++.dg/cpp0x/friend5.C: Likewise.
+
 2019-04-04  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/56643
diff --git a/gcc/testsuite/g++.dg/cpp0x/friend4.C b/gcc/testsuite/g++.dg/cpp0x/friend4.C
new file mode 100644 (file)
index 0000000..6ff53de
--- /dev/null
@@ -0,0 +1,30 @@
+// PR c++/61327
+// { dg-do compile { target c++11 } }
+
+template<typename... T>
+struct A;
+
+template<typename T>
+struct A<T>
+{
+  template<typename U>
+  void f(U* u) {
+    u->T::g();
+  }
+};
+
+struct B {
+protected:
+  void g() { }
+};
+
+struct C : B {
+  template<typename...> friend struct A;
+};
+
+int main()
+{
+  C c;
+  A<B> a;
+  a.f(&c);
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/friend5.C b/gcc/testsuite/g++.dg/cpp0x/friend5.C
new file mode 100644 (file)
index 0000000..39ea28b
--- /dev/null
@@ -0,0 +1,26 @@
+// PR c++/61327
+// { dg-do compile { target c++11 } }
+
+class B {
+protected:
+  void f() {}
+};
+
+template <typename...>
+struct S;
+
+template <typename R>
+struct S<R>{
+    template <typename T>
+    static void caller(T *p) {p->B::f();}
+};
+
+class Q : B{
+template <typename...> friend struct S;
+};
+
+int main(){
+    Q q;
+    S<int>::caller(&q);
+    return 0;
+}