diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 1998-03-29 20:04:28 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 1998-03-29 20:04:28 +0000 |
commit | a4701a9e8617d876e255977a4d94c92921556cc6 (patch) | |
tree | f0d4f4a990921815c1a1fe6d79d25329e9e47388 /gcc | |
parent | 3be647b2d703eb4cc8b5d978e418b635c9cea717 (diff) | |
download | gcc-a4701a9e8617d876e255977a4d94c92921556cc6.tar.gz |
* friend.c (is_friend): Local classes have the same access as the
enclosing function.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@18904 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/friend.c | 37 |
2 files changed, 22 insertions, 20 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b4830ed7ece..62780a46737 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +Sun Mar 29 20:01:59 1998 Jason Merrill <jason@yorick.cygnus.com> + + * friend.c (is_friend): Local classes have the same access as the + enclosing function. + Sun Mar 29 00:47:32 1998 Jeffrey A Law (law@cygnus.com) * typeck.c (expand_target_expr): Delete dead function. diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index f28e049cfa4..d0e6fefbff8 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -41,12 +41,21 @@ is_friend (type, supplicant) { int declp; register tree list; + tree context; if (supplicant == NULL_TREE || type == NULL_TREE) return 0; declp = (TREE_CODE_CLASS (TREE_CODE (supplicant)) == 'd'); + /* Local classes have the same access as the enclosing function. */ + context = hack_decl_function_context (supplicant); + if (context) + { + supplicant = context; + declp = 1; + } + if (declp) /* It's a function decl. */ { @@ -113,26 +122,14 @@ is_friend (type, supplicant) return 1; } - { - tree context; - - if (! declp) - { - /* Are we a nested or local class? If so, we aren't friends - with the CONTEXT. */ - if (IS_AGGR_TYPE (supplicant)) - context = NULL_TREE; - else - context = DECL_CONTEXT (TYPE_MAIN_DECL (supplicant)); - } - else if (DECL_FUNCTION_MEMBER_P (supplicant)) - context = DECL_CLASS_CONTEXT (supplicant); - else - context = NULL_TREE; - - if (context) - return is_friend (type, context); - } + if (declp && DECL_FUNCTION_MEMBER_P (supplicant)) + context = DECL_CLASS_CONTEXT (supplicant); + else + /* Nested classes don't inherit the access of their enclosing class. */ + context = NULL_TREE; + + if (context) + return is_friend (type, context); return 0; } |