diff mbox series

[committed] c++: Add testcase for already fixed PR [PR16617]

Message ID 20210422174312.3233509-1-ppalka@redhat.com
State New
Headers show
Series [committed] c++: Add testcase for already fixed PR [PR16617] | expand

Commit Message

Patrick Palka April 22, 2021, 5:43 p.m. UTC
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 | 25 ++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/template/access36.C
diff mbox series

Patch

diff --git a/gcc/testsuite/g++.dg/template/access36.C b/gcc/testsuite/g++.dg/template/access36.C
new file mode 100644
index 00000000000..72ca23c7017
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/access36.C
@@ -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>();