From: Volker Reichelt Date: Mon, 13 Oct 2003 23:06:37 +0000 (+0000) Subject: re PR c++/12370 (wrong code when adding friend) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=88e451e1e79973615371b41632a39f7e90444c3f;p=gcc.git re PR c++/12370 (wrong code when adding friend) PR c++/12370 * g++.dg/other/friend2.C: New test. * ChangeLog: Add PR number to patch for PR c++/12370. From-SVN: r72446 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9611f33a5a3..240f451bd09 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2003-10-13 Volker Reichelt + + * ChangeLog: Add PR number to patch for PR c++/12370. + 2003-10-13 Gabriel Dos Reis Break out decl.c (2/n) @@ -171,6 +175,7 @@ 2003-09-30 Richard Henderson + PR c++/12370 * decl.c (duplicate_decls): Copy DECL_SAVED_INSNS too. 2003-09-30 Kelley Cook diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 96d41b6558d..77e51a5564a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-10-13 Volker Reichelt + + PR c++/12370 + * g++.dg/other/friend2.C: New test. + 2003-10-12 Steven Bosscher * gcc.dg/20031012-1.c: New test. diff --git a/gcc/testsuite/g++.dg/other/friend2.C b/gcc/testsuite/g++.dg/other/friend2.C new file mode 100644 index 00000000000..ce5d2b741f5 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/friend2.C @@ -0,0 +1,23 @@ +// { dg-do run } +// Origin: Volker Reichelt + +// PR c++/12370 +// Wrong code because of the friend declaration + +template struct A +{ + T x; + A(T t) : x(t) {} + friend A foo (const A&); +}; + +A foo (const A& a) +{ + A res(a.x); + return res; +} + +int main() +{ + return foo(A(0)).x; +}