diff options
author | Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> | 2005-01-06 15:41:34 +0000 |
---|---|---|
committer | Kriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org> | 2005-01-06 15:41:34 +0000 |
commit | 23ff7e2d27290094883a2c4e0414a880209aa7ac (patch) | |
tree | 77e633813ccdf70956ddfce2e7ebc2525e057e33 /gcc | |
parent | d8987adb29b6d98c923d93fcc29ab4d8d47e8a1a (diff) | |
download | gcc-23ff7e2d27290094883a2c4e0414a880209aa7ac.zip gcc-23ff7e2d27290094883a2c4e0414a880209aa7ac.tar.gz gcc-23ff7e2d27290094883a2c4e0414a880209aa7ac.tar.bz2 |
re PR c++/19258 (Incorrect access check for default argument)
PR c++/19258
* pt.c (push_access_scope): Handle friend defined in class.
(pop_access_scope): Likewise.
* g++.dg/lookup/friend6.C: New test.
From-SVN: r92993
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/lookup/friend6.C | 15 |
4 files changed, 30 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fb98595..628d046 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2005-01-06 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> + + PR c++/19258 + * pt.c (push_access_scope): Handle friend defined in class. + (pop_access_scope): Likewise. + 2005-01-06 Nathan Sidwell <nathan@codesourcery.com> PR c++/19270 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index e6f4b51..ad852c5 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -176,7 +176,9 @@ push_access_scope (tree t) gcc_assert (TREE_CODE (t) == FUNCTION_DECL || TREE_CODE (t) == VAR_DECL); - if (DECL_CLASS_SCOPE_P (t)) + if (DECL_FRIEND_CONTEXT (t)) + push_nested_class (DECL_FRIEND_CONTEXT (t)); + else if (DECL_CLASS_SCOPE_P (t)) push_nested_class (DECL_CONTEXT (t)); else push_to_top_level (); @@ -201,7 +203,7 @@ pop_access_scope (tree t) saved_access_scope = TREE_CHAIN (saved_access_scope); } - if (DECL_CLASS_SCOPE_P (t)) + if (DECL_FRIEND_CONTEXT (t) || DECL_CLASS_SCOPE_P (t)) pop_nested_class (); else pop_from_top_level (); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 139d695..8ed16ad 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-01-06 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> + + PR c++/19258 + * g++.dg/lookup/friend6.C: New test. + 2005-01-06 Nathan Sidwell <nathan@codesourcery.com> PR c++/19270 diff --git a/gcc/testsuite/g++.dg/lookup/friend6.C b/gcc/testsuite/g++.dg/lookup/friend6.C new file mode 100644 index 0000000..e3dafb1 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/friend6.C @@ -0,0 +1,15 @@ +// { dg-do compile } + +// Origin: Matt Austern <austern@apple.com> + +// PR c++/19258: Wrong lookup scope for friend defined in class. + +class X { + template<class T> friend int ff(T*, int y=anX.x) { return y; } + int f() { return ff(&anX); } + + static X anX; + int x; +}; + +X dummy; |