summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/other/friend2.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/other/friend2.C')
-rw-r--r--gcc/testsuite/g++.dg/other/friend2.C23
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/other/friend2.C b/gcc/testsuite/g++.dg/other/friend2.C
new file mode 100644
index 000000000..ce5d2b741
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/friend2.C
@@ -0,0 +1,23 @@
+// { dg-do run }
+// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
+
+// PR c++/12370
+// Wrong code because of the friend declaration
+
+template <typename T> struct A
+{
+ T x;
+ A(T t) : x(t) {}
+ friend A<int> foo (const A<unsigned>&);
+};
+
+A<int> foo (const A<unsigned>& a)
+{
+ A<int> res(a.x);
+ return res;
+}
+
+int main()
+{
+ return foo(A<unsigned>(0)).x;
+}