]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/cp/cvt.c
Merge from trunk.
[thirdparty/gcc.git] / gcc / cp / cvt.c
index 5cae99c41e3b3c1701ca291a908c14bd86c7a312..6d0e34156ffced97be1d7f67758f451a0e7a8365 100644 (file)
@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "tm.h"
 #include "tree.h"
+#include "stor-layout.h"
 #include "flags.h"
 #include "cp-tree.h"
 #include "intl.h"
@@ -204,13 +205,13 @@ cp_convert_to_pointer (tree type, tree expr, tsubst_flags_t complain)
 
   if (null_ptr_cst_p (expr))
     {
-      if (complain & tf_warning)
-       maybe_warn_zero_as_null_pointer_constant (expr, loc);
-
       if (TYPE_PTRMEMFUNC_P (type))
        return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), expr, 0,
                                 /*c_cast_p=*/false, complain);
 
+      if (complain & tf_warning)
+       maybe_warn_zero_as_null_pointer_constant (expr, loc);
+
       /* A NULL pointer-to-data-member is represented by -1, not by
         zero.  */
       tree val = (TYPE_PTRDATAMEM_P (type)
@@ -1589,17 +1590,6 @@ build_expr_type_conversion (int desires, tree expr, bool complain)
       if (DECL_NONCONVERTING_P (cand))
        continue;
 
-      if (TREE_CODE (cand) == TEMPLATE_DECL)
-       {
-         if (complain)
-           {
-             error ("ambiguous default type conversion from %qT",
-                    basetype);
-             error ("  candidate conversions include %qD", cand);
-           }
-         return error_mark_node;
-       }
-
       candidate = non_reference (TREE_TYPE (TREE_TYPE (cand)));
 
       switch (TREE_CODE (candidate))
@@ -1633,11 +1623,23 @@ build_expr_type_conversion (int desires, tree expr, bool complain)
          break;
 
        default:
+         /* A wildcard could be instantiated to match any desired
+            type, but we can't deduce the template argument.  */
+         if (WILDCARD_TYPE_P (candidate))
+           win = true;
          break;
        }
 
       if (win)
        {
+         if (TREE_CODE (cand) == TEMPLATE_DECL)
+           {
+             if (complain)
+               error ("default type conversion can't deduce template"
+                      " argument for %qD", cand);
+             return error_mark_node;
+           }
+
          if (winner)
            {
              tree winner_type