OSDN Git Service

PR c++/43509
[pf3gnuchains/gcc-fork.git] / gcc / cp / call.c
index 3cb30a5..2dc73f5 100644 (file)
@@ -1246,7 +1246,7 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags)
      type, so that we can later do a const_cast to the desired type.  */
   if (related_p && c_cast_p
       && !at_least_as_qualified_p (to, tfrom))
-    to = cp_build_qualified_type (to, cp_type_quals (tfrom));
+    to = build_qualified_type (to, cp_type_quals (tfrom));
   compatible_p = reference_compatible_p (to, tfrom);
 
   /* Directly bind reference when target expression's type is compatible with
@@ -1617,8 +1617,9 @@ add_function_candidate (struct z_candidate **candidates,
             parameter, we can just change the parm type.  */
          if (ctype && is_this)
            {
-             parmtype = cp_build_qualified_type
-               (ctype, cp_type_quals (TREE_TYPE (parmtype)));
+             parmtype
+               = build_qualified_type (ctype,
+                                       TYPE_QUALS (TREE_TYPE (parmtype)));
              parmtype = build_pointer_type (parmtype);
            }
 
@@ -2958,11 +2959,33 @@ build_user_type_conversion_1 (tree totype, tree expr, int flags)
 
       for (cand = candidates; cand != old_candidates; cand = cand->next)
        {
-         conversion *ics
-           = implicit_conversion (totype,
-                                  TREE_TYPE (TREE_TYPE (cand->fn)),
-                                  0,
-                                  /*c_cast_p=*/false, convflags);
+         tree fn = OVL_CURRENT (fns);
+
+         if (DECL_NONCONVERTING_P (fn)
+             && (flags & LOOKUP_ONLYCONVERTING))
+           continue;
+
+         /* [over.match.funcs] For conversion functions, the function
+            is considered to be a member of the class of the implicit
+            object argument for the purpose of defining the type of
+            the implicit object parameter.
+
+            So we pass fromtype as CTYPE to add_*_candidate.  */
+
+         if (TREE_CODE (fn) == TEMPLATE_DECL)
+           cand = add_template_candidate (&candidates, fn, fromtype,
+                                          NULL_TREE,
+                                          first_arg, NULL, totype,
+                                          TYPE_BINFO (fromtype),
+                                          conversion_path,
+                                          flags,
+                                          DEDUCE_CONV);
+         else
+           cand = add_function_candidate (&candidates, fn, fromtype,
+                                          first_arg, NULL,
+                                          TYPE_BINFO (fromtype),
+                                          conversion_path,
+                                          flags);
 
          /* If LOOKUP_NO_TEMP_BIND isn't set, then this is
             copy-initialization.  In that case, "The result of the
@@ -3355,11 +3378,21 @@ build_op_call (tree obj, VEC(tree,gc) **args, tsubst_flags_t complain)
     {
       first_mem_arg = build_this (obj);
 
-      add_candidates (BASELINK_FUNCTIONS (fns),
-                     first_mem_arg, *args, NULL_TREE,
-                     NULL_TREE, false,
-                     BASELINK_BINFO (fns), BASELINK_ACCESS_BINFO (fns),
-                     LOOKUP_NORMAL, &candidates);
+      for (fns = BASELINK_FUNCTIONS (fns); fns; fns = OVL_NEXT (fns))
+       {
+         tree fn = OVL_CURRENT (fns);
+
+         if (TREE_CODE (fn) == TEMPLATE_DECL)
+           add_template_candidate (&candidates, fn, base, NULL_TREE,
+                                   first_mem_arg, *args, NULL_TREE,
+                                   TYPE_BINFO (type),
+                                   TYPE_BINFO (type),
+                                   LOOKUP_NORMAL, DEDUCE_CALL);
+         else
+           add_function_candidate
+             (&candidates, fn, base, first_mem_arg, *args, TYPE_BINFO (type),
+              TYPE_BINFO (type), LOOKUP_NORMAL);
+       }
     }
 
   convs = lookup_conversions (type, /*lookup_template_convs_p=*/true);
@@ -3776,11 +3809,11 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3,
         the type of the other.  */
       if ((conv2 || conv3)
          && CLASS_TYPE_P (arg2_type)
-         && cp_type_quals (arg2_type) != cp_type_quals (arg3_type))
+         && TYPE_QUALS (arg2_type) != TYPE_QUALS (arg3_type))
        arg2_type = arg3_type =
          cp_build_qualified_type (arg2_type,
-                                  cp_type_quals (arg2_type)
-                                  | cp_type_quals (arg3_type));
+                                  TYPE_QUALS (arg2_type)
+                                  | TYPE_QUALS (arg3_type));
     }
 
   /* [expr.cond]
@@ -4996,7 +5029,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
          }
        /* Build up the array.  */
        elttype = cp_build_qualified_type
-         (elttype, cp_type_quals (elttype) | TYPE_QUAL_CONST);
+         (elttype, TYPE_QUALS (elttype) | TYPE_QUAL_CONST);
        array = build_array_of_n_type (elttype, len);
        array = finish_compound_literal (array, new_ctor);
 
@@ -5377,7 +5410,7 @@ type_passed_as (tree type)
     {
       type = build_reference_type (type);
       /* There are no other pointers to this temporary.  */
-      type = cp_build_qualified_type (type, TYPE_QUAL_RESTRICT);
+      type = build_qualified_type (type, TYPE_QUAL_RESTRICT);
     }
   else if (targetm.calls.promote_prototypes (type)
           && INTEGRAL_TYPE_P (type)
@@ -7734,7 +7767,7 @@ initialize_reference (tree type, tree expr, tree decl, tree *cleanup,
     {
       if (complain & tf_error)
        {
-         if (!CP_TYPE_CONST_P (TREE_TYPE (type))
+         if (!(TYPE_QUALS (TREE_TYPE (type)) & TYPE_QUAL_CONST)
              && !TYPE_REF_IS_RVALUE (type)
              && !real_lvalue_p (expr))
            error ("invalid initialization of non-const reference of "