re PR c++/17585 (usage of unqualified name of static member from within class not...
authorMark Mitchell <mark@codesourcery.com>
Mon, 27 Sep 2004 18:47:29 +0000 (18:47 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Mon, 27 Sep 2004 18:47:29 +0000 (18:47 +0000)
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

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/search.c
gcc/cp/semantics.c

index 34faa4789c5a390e14a5e654cd22499e0fc66c5f..028e0e10d1e97e0da9f7e027838275c55f4d14ee 100644 (file)
@@ -1,5 +1,11 @@
 2004-09-27  Mark Mitchell  <mark@codesourcery.com>
 
+       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.
index 4976894703ae061e53b369921c8f9ea2107a9d9b..3c9ea57fda9a027dac5b664adc70cbc3f87c81f4 100644 (file)
@@ -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);
index 96d273be195c78ff947a5c10ffb5e293a1cd2cf1..47d08f34c74c9d764145f9b13ee436b243f7f713 100644 (file)
@@ -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 \
index d966f284c13b157317eaeb5e75d12f070de79bd4..54abf9365281fa28ee0f844cd7e19b129b7231f6 100644 (file)
@@ -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);