Commit d50c6443 by Jason Merrill Committed by Jason Merrill

friend.c (is_friend): Local classes have the same access as the enclosing function.

	* friend.c (is_friend): Local classes have the same access as the
	enclosing function.

From-SVN: r18904
parent 77f484de
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) Sun Mar 29 00:47:32 1998 Jeffrey A Law (law@cygnus.com)
* typeck.c (expand_target_expr): Delete dead function. * typeck.c (expand_target_expr): Delete dead function.
......
...@@ -41,12 +41,21 @@ is_friend (type, supplicant) ...@@ -41,12 +41,21 @@ is_friend (type, supplicant)
{ {
int declp; int declp;
register tree list; register tree list;
tree context;
if (supplicant == NULL_TREE || type == NULL_TREE) if (supplicant == NULL_TREE || type == NULL_TREE)
return 0; return 0;
declp = (TREE_CODE_CLASS (TREE_CODE (supplicant)) == 'd'); 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) if (declp)
/* It's a function decl. */ /* It's a function decl. */
{ {
...@@ -113,26 +122,14 @@ is_friend (type, supplicant) ...@@ -113,26 +122,14 @@ is_friend (type, supplicant)
return 1; return 1;
} }
{ if (declp && DECL_FUNCTION_MEMBER_P (supplicant))
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); context = DECL_CLASS_CONTEXT (supplicant);
else else
/* Nested classes don't inherit the access of their enclosing class. */
context = NULL_TREE; context = NULL_TREE;
if (context) if (context)
return is_friend (type, context); return is_friend (type, context);
}
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment