OSDN Git Service

PR c++/561
[pf3gnuchains/gcc-fork.git] / gcc / cp / class.c
index 4020144..3cf15fb 100644 (file)
@@ -4104,6 +4104,7 @@ adjust_clone_args (tree decl)
              /* A default parameter has been added. Adjust the
                 clone's parameters.  */
              tree exceptions = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (clone));
+             tree attrs = TYPE_ATTRIBUTES (TREE_TYPE (clone));
              tree basetype = TYPE_METHOD_BASETYPE (TREE_TYPE (clone));
              tree type;
 
@@ -4121,6 +4122,8 @@ adjust_clone_args (tree decl)
                                                 clone_parms);
              if (exceptions)
                type = build_exception_variant (type, exceptions);
+             if (attrs)
+               type = cp_build_type_attribute_variant (type, attrs);
              TREE_TYPE (clone) = type;
 
              clone_parms = NULL_TREE;
@@ -6062,6 +6065,7 @@ resolve_address_of_overloaded_function (tree target_type,
      interoperability with most_specialized_instantiation.  */
   tree matches = NULL_TREE;
   tree fn;
+  tree target_fn_type;
 
   /* By the time we get here, we should be seeing only real
      pointer-to-member types, not the internal POINTER_TYPE to
@@ -6093,6 +6097,15 @@ resolve_address_of_overloaded_function (tree target_type,
       return error_mark_node;
     }
 
+  /* Non-member functions and static member functions match targets of type
+     "pointer-to-function" or "reference-to-function."  Nonstatic member
+     functions match targets of type "pointer-to-member-function;" the
+     function type of the pointer to member is used to select the member
+     function from the set of overloaded member functions.
+
+     So figure out the FUNCTION_TYPE that we want to match against.  */
+  target_fn_type = static_fn_type (target_type);
+
   /* If we can find a non-template function that matches, we can just
      use it.  There's no point in generating template instantiations
      if we're just going to throw them out anyhow.  But, of course, we
@@ -6104,7 +6117,6 @@ resolve_address_of_overloaded_function (tree target_type,
       for (fns = overload; fns; fns = OVL_NEXT (fns))
        {
          tree fn = OVL_CURRENT (fns);
-         tree fntype;
 
          if (TREE_CODE (fn) == TEMPLATE_DECL)
            /* We're not looking for templates just yet.  */
@@ -6122,13 +6134,7 @@ resolve_address_of_overloaded_function (tree target_type,
            continue;
 
          /* See if there's a match.  */
-         fntype = TREE_TYPE (fn);
-         if (is_ptrmem)
-           fntype = build_ptrmemfunc_type (build_pointer_type (fntype));
-         else if (!is_reference)
-           fntype = build_pointer_type (fntype);
-
-         if (can_convert_arg (target_type, fntype, fn, LOOKUP_NORMAL))
+         if (same_type_p (target_fn_type, static_fn_type (fn)))
            matches = tree_cons (fn, NULL_TREE, matches);
        }
     }
@@ -6138,7 +6144,6 @@ resolve_address_of_overloaded_function (tree target_type,
      match we need to look at them, too.  */
   if (!matches)
     {
-      tree target_fn_type;
       tree target_arg_types;
       tree target_ret_type;
       tree fns;
@@ -6146,18 +6151,9 @@ resolve_address_of_overloaded_function (tree target_type,
       unsigned int nargs, ia;
       tree arg;
 
-      if (is_ptrmem)
-       target_fn_type
-         = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (target_type));
-      else
-       target_fn_type = TREE_TYPE (target_type);
       target_arg_types = TYPE_ARG_TYPES (target_fn_type);
       target_ret_type = TREE_TYPE (target_fn_type);
 
-      /* Never do unification on the 'this' parameter.  */
-      if (TREE_CODE (target_fn_type) == METHOD_TYPE)
-       target_arg_types = TREE_CHAIN (target_arg_types);
-
       nargs = list_length (target_arg_types);
       args = XALLOCAVEC (tree, nargs);
       for (arg = target_arg_types, ia = 0;
@@ -6170,7 +6166,6 @@ resolve_address_of_overloaded_function (tree target_type,
        {
          tree fn = OVL_CURRENT (fns);
          tree instantiation;
-         tree instantiation_type;
          tree targs;
 
          if (TREE_CODE (fn) != TEMPLATE_DECL)
@@ -6198,14 +6193,7 @@ resolve_address_of_overloaded_function (tree target_type,
            continue;
 
          /* See if there's a match.  */
-         instantiation_type = TREE_TYPE (instantiation);
-         if (is_ptrmem)
-           instantiation_type =
-             build_ptrmemfunc_type (build_pointer_type (instantiation_type));
-         else if (!is_reference)
-           instantiation_type = build_pointer_type (instantiation_type);
-         if (can_convert_arg (target_type, instantiation_type, instantiation,
-                              LOOKUP_NORMAL))
+         if (same_type_p (target_fn_type, static_fn_type (instantiation)))
            matches = tree_cons (instantiation, fn, matches);
        }