#include "tree.h"
#include "flags.h"
#include "cp-tree.h"
+#include "intl.h"
#include "convert.h"
#include "toplev.h"
#include "decl.h"
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);
}
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);
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
&& !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;
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;
/* 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