From: Mark Mitchell Date: Tue, 13 Sep 2005 14:44:08 +0000 (+0000) Subject: re PR c++/23842 (Incorrect access control context) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6493555fd370845f620a17553d2013a8acad2f93;p=gcc.git re PR c++/23842 (Incorrect access control context) 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. From-SVN: r104224 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cd19181dafc..e0d24ec3e10 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 07054ecf314..bcff043c188 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 37d8a45407b..5322f23a28d 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 00000000000..bb7ebccb8b5 --- /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); +} +