OSDN Git Service

* config/sh/sh.c (find_barrier): Don't emit a CP inside the GP setting.
[pf3gnuchains/gcc-fork.git] / gcc / cp / cvt.c
index 88ae05a..9dd0c59 100644 (file)
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree.h"
 #include "flags.h"
 #include "cp-tree.h"
+#include "intl.h"
 #include "convert.h"
 #include "toplev.h"
 #include "decl.h"
@@ -367,17 +368,17 @@ warn_ref_binding (tree reftype, tree intype, tree decl)
       const char *msg;
 
       if (CP_TYPE_VOLATILE_P (ttl) && decl)
-         msg = "initialization of volatile reference type %q#T from"
-           " rvalue of type %qT";
+       msg = G_("initialization of volatile reference type %q#T from "
+                "rvalue of type %qT");
       else if (CP_TYPE_VOLATILE_P (ttl))
-         msg = "conversion to volatile reference type %q#T "
-           " from rvalue of type %qT";
+       msg = G_("conversion to volatile reference type %q#T "
+                "from rvalue of type %qT");
       else if (decl)
-         msg = "initialization of non-const reference type %q#T from"
-           " rvalue of type %qT";
+       msg = G_("initialization of non-const reference type %q#T from "
+                "rvalue of type %qT");
       else
-         msg = "conversion to non-const reference type %q#T from"
-           " rvalue of type %qT";
+       msg = G_("conversion to non-const reference type %q#T from "
+                "rvalue of type %qT");
 
       permerror (input_location, msg, reftype, intype);
     }
@@ -506,7 +507,8 @@ convert_to_reference (tree reftype, tree expr, int convtype,
 tree
 convert_from_reference (tree val)
 {
-  if (TREE_CODE (TREE_TYPE (val)) == REFERENCE_TYPE)
+  if (TREE_TYPE (val)
+      && TREE_CODE (TREE_TYPE (val)) == REFERENCE_TYPE)
     {
       tree t = TREE_TYPE (TREE_TYPE (val));
       tree ref = build1 (INDIRECT_REF, t, val);
@@ -539,7 +541,16 @@ force_rvalue (tree expr)
 
   return expr;
 }
+
 \f
+/* Fold away simple conversions, but make sure the result is an rvalue.  */
+
+tree
+cp_fold_convert (tree type, tree expr)
+{
+  return rvalue (fold_convert (type, expr));
+}
+
 /* C++ conversions, preference to static cast conversions.  */
 
 tree
@@ -936,16 +947,18 @@ convert_to_void (tree expr, const char *implicit, tsubst_flags_t complain)
              && !AGGR_INIT_VIA_CTOR_P (init))
            {
              tree fn = AGGR_INIT_EXPR_FN (init);
-             expr = build_call_array (TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))),
-                                      fn,
-                                      aggr_init_expr_nargs (init),
-                                      AGGR_INIT_EXPR_ARGP (init));
+             expr = build_call_array_loc (input_location,
+                                          TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))),
+                                          fn,
+                                          aggr_init_expr_nargs (init),
+                                          AGGR_INIT_EXPR_ARGP (init));
            }
        }
       break;
 
     default:;
     }
+  expr = resolve_nondeduced_context (expr);
   {
     tree probe = expr;
 
@@ -1184,11 +1197,14 @@ build_expr_type_conversion (int desires, tree expr, bool complain)
   if (!TYPE_HAS_CONVERSION (basetype))
     return NULL_TREE;
 
-  for (conv = lookup_conversions (basetype); conv; conv = TREE_CHAIN (conv))
+  for (conv = lookup_conversions (basetype, /*lookup_template_convs_p=*/true);
+       conv;
+       conv = TREE_CHAIN (conv))
     {
       int win = 0;
       tree candidate;
       tree cand = TREE_VALUE (conv);
+      cand = OVL_CURRENT (cand);
 
       if (winner && winner == cand)
        continue;
@@ -1277,7 +1293,7 @@ type_promotes_to (tree type)
 
   /* bool always promotes to int (not unsigned), even if it's the same
      size.  */
-  if (type == boolean_type_node)
+  if (TREE_CODE (type) == BOOLEAN_TYPE)
     type = integer_type_node;
 
   /* Normally convert enums to int, but convert wide enums to something