From fc72e1eae2383dc1ae3dd68e72108b216e641967 Mon Sep 17 00:00:00 2001 From: mmitchel Date: Tue, 13 Sep 2005 14:44:08 +0000 Subject: [PATCH] PR c++/23842 * pt.c (tsubst_default_argument): Do treat default argument expressions as occurring in the context of the function called. PR c++/23842 * g++.dg/template/access16.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@104224 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 4 ---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/access16.C | 16 ++++++++++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/access16.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cd19181..e0d24ec 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2005-09-13 Mark Mitchell + + PR c++/23842 + * pt.c (tsubst_default_argument): Do treat default argument + expressions as occurring in the context of the function called. + 2005-09-12 Mark Mitchell PR c++/23841 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 07054ec..bcff043 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6097,10 +6097,6 @@ tsubst_default_argument (tree fn, tree type, tree arg) we must be careful to do name lookup in the scope of S, rather than in the current class. */ push_access_scope (fn); - /* The default argument expression should not be considered to be - within the scope of FN. Since push_access_scope sets - current_function_decl, we must explicitly clear it here. */ - current_function_decl = NULL_TREE; /* The "this" pointer is not valid in a default argument. */ if (cfun) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 37d8a45..5322f23 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-09-13 Mark Mitchell + + PR c++/23842 + * g++.dg/template/access16.C: New test. + 2005-09-13 Richard Sandiford * gfortran.dg/char_pack_2.f90: Increase the vector size. diff --git a/gcc/testsuite/g++.dg/template/access16.C b/gcc/testsuite/g++.dg/template/access16.C new file mode 100644 index 0000000..bb7ebcc --- /dev/null +++ b/gcc/testsuite/g++.dg/template/access16.C @@ -0,0 +1,16 @@ +// PR c++/23842 + +struct S; +extern S *p; +template int f(T*, int y = ((T*)p)->x) { + return y; +} +struct S { +private: + int x; + template friend int f(U*, int); +}; +int g() { + return f(p); +} + -- 2.7.4