diff options
author | Mark Mitchell <mark@codesourcery.com> | 2005-09-13 14:44:08 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2005-09-13 14:44:08 +0000 |
commit | 6493555fd370845f620a17553d2013a8acad2f93 (patch) | |
tree | 963c8b8c471c5d3e0f0a9c9cb8a697bfc10d11f5 /gcc | |
parent | 8abbec474896d0c2d341c18993a706fa731394cd (diff) | |
download | gcc-6493555fd370845f620a17553d2013a8acad2f93.zip gcc-6493555fd370845f620a17553d2013a8acad2f93.tar.gz gcc-6493555fd370845f620a17553d2013a8acad2f93.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/access16.C | 16 |
4 files changed, 27 insertions, 4 deletions
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 <mark@codesourcery.com> + + 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 <mark@codesourcery.com> 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<T>, 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 <mark@codesourcery.com> + + PR c++/23842 + * g++.dg/template/access16.C: New test. + 2005-09-13 Richard Sandiford <richard@codesourcery.com> * 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 <class T> int f(T*, int y = ((T*)p)->x) { + return y; +} +struct S { +private: + int x; + template <class U> friend int f(U*, int); +}; +int g() { + return f(p); +} + |