From: Mark Mitchell Date: Mon, 27 Sep 2004 18:47:29 +0000 (+0000) Subject: re PR c++/17585 (usage of unqualified name of static member from within class not... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=821eaf2a80a5c88a162f440028c6c4574f70585a;p=gcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 34faa4789c5..028e0e10d1e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2004-09-27 Mark Mitchell + 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 static member functions. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 4976894703a..3c9ea57fda9 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4023,6 +4023,7 @@ extern tree adjust_result_of_qualified_name_lookup (tree, tree, tree); extern tree copied_binfo (tree, tree); extern tree original_binfo (tree, tree); +extern int shared_member_p (tree); /* in semantics.c */ extern void push_deferring_access_checks (deferring_kind); diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 96d273be195..47d08f34c74 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -56,7 +56,6 @@ static int lookup_conversions_r (tree, int, int, tree, tree, tree, tree, tree *, tree *); static int look_for_overrides_r (tree, tree); static tree lookup_field_queue_p (tree, int, void *); -static int shared_member_p (tree); static tree lookup_field_r (tree, void *); static tree dfs_accessible_queue_p (tree, int, void *); static tree dfs_accessible_p (tree, void *); @@ -1025,7 +1024,7 @@ template_self_reference_p (tree type, tree decl) This function checks that T contains no nonstatic members. */ -static int +int shared_member_p (tree t) { if (TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == TYPE_DECL \ diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index d966f284c13..54abf936528 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1426,19 +1426,16 @@ finish_qualified_id_expr (tree qualifying_class, tree expr, bool done, qualifying_class); else if (BASELINK_P (expr) && !processing_template_decl) { - tree fn; tree fns; /* See if any of the functions are non-static members. */ fns = BASELINK_FUNCTIONS (expr); if (TREE_CODE (fns) == TEMPLATE_ID_EXPR) 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 class. */ - if (fn && current_class_type + if (!shared_member_p (fns) + && current_class_type && DERIVED_FROM_P (qualifying_class, current_class_type)) expr = (build_class_member_access_expr (maybe_dummy_object (qualifying_class, NULL), @@ -2646,7 +2643,8 @@ finish_id_expression (tree id_expression, mark_used (first_fn); 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. */ decl = maybe_dummy_object (DECL_CONTEXT (first_fn), 0);