Commit 7ac2c0bd by Jason Merrill Committed by Jason Merrill

re PR c++/66957 (incorrect "is protected within this context" error)

	PR c++/66957
	* search.c (protected_accessible_p): Remove redundant access_in_type.
	Add otype parm instead of walking binfo.
	(friend_accessible_p): Check SCOPE itself.  Handle class
	templates.  Pass through otype.
	(dfs_accessible_post): Handle all accessibility cases.
	(dfs_accessible_pre): New.
	(accessible_p): Use it.  Don't check protected access here.  Pass
	decl and otype to dfs_walk.
	(member_declared_in_type, dfs_access_in_type_pre): New.
	(access_in_type): Use dfs_access_in_type_pre.
	* friend.c (add_friend): Fix multiple friends with the same name.

From-SVN: r227023
parent 18c4fa8e
2015-08-19 Jason Merrill <jason@redhat.com>
PR c++/66957
* search.c (protected_accessible_p): Remove redundant access_in_type.
Add otype parm instead of walking binfo.
(friend_accessible_p): Check SCOPE itself. Handle class
templates. Pass through otype.
(dfs_accessible_post): Handle all accessibility cases.
(dfs_accessible_pre): New.
(accessible_p): Use it. Don't check protected access here. Pass
decl and otype to dfs_walk.
(member_declared_in_type, dfs_access_in_type_pre): New.
(access_in_type): Use dfs_access_in_type_pre.
* friend.c (add_friend): Fix multiple friends with the same name.
* lambda.c (current_nonlambda_scope): New.
2015-08-18 Trevor Saunders <tbsaunde@tbsaunde.org>
......
......@@ -156,11 +156,9 @@ add_friend (tree type, tree decl, bool complain)
}
}
maybe_add_class_template_decl_list (type, decl, /*friend_p=*/1);
TREE_VALUE (list) = tree_cons (NULL_TREE, decl,
TREE_VALUE (list));
return;
break;
}
list = TREE_CHAIN (list);
}
......@@ -172,9 +170,10 @@ add_friend (tree type, tree decl, bool complain)
maybe_add_class_template_decl_list (type, decl, /*friend_p=*/1);
DECL_FRIENDLIST (typedecl)
= tree_cons (DECL_NAME (decl), build_tree_list (NULL_TREE, decl),
DECL_FRIENDLIST (typedecl));
if (!list)
DECL_FRIENDLIST (typedecl)
= tree_cons (DECL_NAME (decl), build_tree_list (NULL_TREE, decl),
DECL_FRIENDLIST (typedecl));
if (!uses_template_parms (type))
DECL_BEFRIENDING_CLASSES (decl)
= tree_cons (NULL_TREE, type,
......
// PR c++/66957
class BaseClass {
protected:
static int x;
};
struct DerivedA : BaseClass { };
struct DerivedB : BaseClass {
DerivedB() {
(void) DerivedA::x;
}
};
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