c++: Add testcase for already fixed PR [PR16617]
authorPatrick Palka <ppalka@redhat.com>
Thu, 22 Apr 2021 17:32:40 +0000 (13:32 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 22 Apr 2021 17:32:40 +0000 (13:32 -0400)
We correctly diagnose the invalid access since r11-1350.

gcc/testsuite/ChangeLog:

PR c++/16617
* g++.dg/template/access36.C: New test.

gcc/testsuite/g++.dg/template/access36.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/template/access36.C b/gcc/testsuite/g++.dg/template/access36.C
new file mode 100644 (file)
index 0000000..72ca23c
--- /dev/null
@@ -0,0 +1,25 @@
+// PR c++/16617
+
+class B
+{
+  protected:
+  int i;
+};
+
+template <class T> void fr ();
+
+class D2 : public B
+{
+  friend void fr<int> ();
+};
+
+template<int B::*> struct X
+{};
+
+template <class T> void fr ()
+{
+  X<&B::i> x1;  // { dg-error "protected" }
+  X<&D2::i> x2; // { dg-error "protected" }
+}
+
+template void fr<char>();