Commit 821eaf2a by Mark Mitchell Committed by Mark Mitchell

re PR c++/17585 (usage of unqualified name of static member from within class not allowed)

	PR c++/17585
	* cp-tree.h (shared_member_p): Declare.
	* search.c (shared_member_p): Give it external linkage.
	* semantics.c (finish_qualified_id_expr): Use it.
	(finish_id_expression): Likewise.

From-SVN: r88188
parent 7e200b50
2004-09-27 Mark Mitchell <mark@codesourcery.com> 2004-09-27 Mark Mitchell <mark@codesourcery.com>
PR c++/17585 PR c++/17585
* cp-tree.h (shared_member_p): Declare.
* search.c (shared_member_p): Give it external linkage.
* semantics.c (finish_qualified_id_expr): Use it.
(finish_id_expression): Likewise.
PR c++/17585
* semantics.c (finish_id_expression): Do not add "this->" to * semantics.c (finish_id_expression): Do not add "this->" to
static member functions. static member functions.
......
...@@ -4023,6 +4023,7 @@ extern tree adjust_result_of_qualified_name_lookup ...@@ -4023,6 +4023,7 @@ extern tree adjust_result_of_qualified_name_lookup
(tree, tree, tree); (tree, tree, tree);
extern tree copied_binfo (tree, tree); extern tree copied_binfo (tree, tree);
extern tree original_binfo (tree, tree); extern tree original_binfo (tree, tree);
extern int shared_member_p (tree);
/* in semantics.c */ /* in semantics.c */
extern void push_deferring_access_checks (deferring_kind); extern void push_deferring_access_checks (deferring_kind);
......
...@@ -56,7 +56,6 @@ static int lookup_conversions_r (tree, int, int, ...@@ -56,7 +56,6 @@ static int lookup_conversions_r (tree, int, int,
tree, tree, tree, tree, tree *, tree *); tree, tree, tree, tree, tree *, tree *);
static int look_for_overrides_r (tree, tree); static int look_for_overrides_r (tree, tree);
static tree lookup_field_queue_p (tree, int, void *); static tree lookup_field_queue_p (tree, int, void *);
static int shared_member_p (tree);
static tree lookup_field_r (tree, void *); static tree lookup_field_r (tree, void *);
static tree dfs_accessible_queue_p (tree, int, void *); static tree dfs_accessible_queue_p (tree, int, void *);
static tree dfs_accessible_p (tree, void *); static tree dfs_accessible_p (tree, void *);
...@@ -1025,7 +1024,7 @@ template_self_reference_p (tree type, tree decl) ...@@ -1025,7 +1024,7 @@ template_self_reference_p (tree type, tree decl)
This function checks that T contains no nonstatic members. */ This function checks that T contains no nonstatic members. */
static int int
shared_member_p (tree t) shared_member_p (tree t)
{ {
if (TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == TYPE_DECL \ if (TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == TYPE_DECL \
......
...@@ -1426,19 +1426,16 @@ finish_qualified_id_expr (tree qualifying_class, tree expr, bool done, ...@@ -1426,19 +1426,16 @@ finish_qualified_id_expr (tree qualifying_class, tree expr, bool done,
qualifying_class); qualifying_class);
else if (BASELINK_P (expr) && !processing_template_decl) else if (BASELINK_P (expr) && !processing_template_decl)
{ {
tree fn;
tree fns; tree fns;
/* See if any of the functions are non-static members. */ /* See if any of the functions are non-static members. */
fns = BASELINK_FUNCTIONS (expr); fns = BASELINK_FUNCTIONS (expr);
if (TREE_CODE (fns) == TEMPLATE_ID_EXPR) if (TREE_CODE (fns) == TEMPLATE_ID_EXPR)
fns = TREE_OPERAND (fns, 0); fns = TREE_OPERAND (fns, 0);
for (fn = fns; fn; fn = OVL_NEXT (fn))
if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fn))
break;
/* If so, the expression may be relative to the current /* If so, the expression may be relative to the current
class. */ class. */
if (fn && current_class_type if (!shared_member_p (fns)
&& current_class_type
&& DERIVED_FROM_P (qualifying_class, current_class_type)) && DERIVED_FROM_P (qualifying_class, current_class_type))
expr = (build_class_member_access_expr expr = (build_class_member_access_expr
(maybe_dummy_object (qualifying_class, NULL), (maybe_dummy_object (qualifying_class, NULL),
...@@ -2646,7 +2643,8 @@ finish_id_expression (tree id_expression, ...@@ -2646,7 +2643,8 @@ finish_id_expression (tree id_expression,
mark_used (first_fn); mark_used (first_fn);
if (TREE_CODE (first_fn) == FUNCTION_DECL if (TREE_CODE (first_fn) == FUNCTION_DECL
&& DECL_NONSTATIC_MEMBER_FUNCTION_P (first_fn)) && DECL_FUNCTION_MEMBER_P (first_fn)
&& !shared_member_p (decl))
{ {
/* A set of member functions. */ /* A set of member functions. */
decl = maybe_dummy_object (DECL_CONTEXT (first_fn), 0); decl = maybe_dummy_object (DECL_CONTEXT (first_fn), 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