static void maybe_warn_class_memaccess (location_t, tree,
const vec<tree, va_gc> *);
static tree build_over_call (struct z_candidate *, int, tsubst_flags_t);
-#define convert_like(CONV, EXPR, COMPLAIN) \
- convert_like_real ((CONV), (EXPR), NULL_TREE, 0, \
- /*issue_conversion_warnings=*/true, \
- /*c_cast_p=*/false, (COMPLAIN))
-#define convert_like_with_context(CONV, EXPR, FN, ARGNO, COMPLAIN ) \
- convert_like_real ((CONV), (EXPR), (FN), (ARGNO), \
- /*issue_conversion_warnings=*/true, \
- /*c_cast_p=*/false, (COMPLAIN))
-static tree convert_like_real (conversion *, tree, tree, int, bool,
- bool, tsubst_flags_t);
-static tree convert_like_real_1 (conversion *, tree, tree, int, bool,
- bool, tsubst_flags_t);
+static tree convert_like (conversion *, tree, tsubst_flags_t);
+static tree convert_like_with_context (conversion *, tree, tree, int,
+ tsubst_flags_t);
static void op_error (const op_location_t &, enum tree_code, enum tree_code,
tree, tree, tree, bool);
static struct z_candidate *build_user_type_conversion_1 (tree, tree, int,
{
from = type_decays_to (from);
fcode = TREE_CODE (from);
- /* Tell convert_like_real that we're using the address. */
+ /* Tell convert_like that we're using the address. */
conv->rvaluedness_matches_p = true;
conv = build_conv (ck_lvalue, from, conv);
}
}
conv = build_conv (ck_rvalue, from, conv);
if (flags & LOOKUP_PREFER_RVALUE)
- /* Tell convert_like_real to set LOOKUP_PREFER_RVALUE. */
+ /* Tell convert_like to set LOOKUP_PREFER_RVALUE. */
conv->rvaluedness_matches_p = true;
/* If we're performing copy-initialization, remember to skip
explicit constructors. */
the conversion unless we're binding directly to a reference. */
conv->need_temporary_p = !(flags & LOOKUP_NO_TEMP_BIND);
if (flags & LOOKUP_PREFER_RVALUE)
- /* Tell convert_like_real to set LOOKUP_PREFER_RVALUE. */
+ /* Tell convert_like to set LOOKUP_PREFER_RVALUE. */
conv->rvaluedness_matches_p = true;
/* If we're performing copy-initialization, remember to skip
explicit constructors. */
t = build_identity_conv (argtype, NULL_TREE);
t = build_conv (ck_user, totype, t);
/* Leave the 'cand' field null; we'll figure out the conversion in
- convert_like_real if this candidate is chosen. */
+ convert_like if this candidate is chosen. */
convert_type = totype;
}
else if (parmnode == void_list_node)
"are only available with %<-std=c++20%> or %<-std=gnu++20%>");
}
-/* Wrapper for convert_like_real_1 that handles creating IMPLICIT_CONV_EXPR. */
-
-static tree
-convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
- bool issue_conversion_warnings,
- bool c_cast_p, tsubst_flags_t complain)
-{
- /* Creating &TARGET_EXPR<> in a template breaks when substituting,
- and creating a CALL_EXPR in a template breaks in finish_call_expr
- so use an IMPLICIT_CONV_EXPR for this conversion. We would have
- created such codes e.g. when calling a user-defined conversion
- function. */
- tree conv_expr = NULL_TREE;
- if (processing_template_decl
- && convs->kind != ck_identity
- && (CLASS_TYPE_P (convs->type) || CLASS_TYPE_P (TREE_TYPE (expr))))
- {
- conv_expr = build1 (IMPLICIT_CONV_EXPR, convs->type, expr);
- if (convs->kind != ck_ref_bind)
- conv_expr = convert_from_reference (conv_expr);
- if (!convs->bad_p)
- return conv_expr;
- /* Do the normal processing to give the bad_p errors. But we still
- need to return the IMPLICIT_CONV_EXPR, unless we're returning
- error_mark_node. */
- }
- expr = convert_like_real_1 (convs, expr, fn, argnum,
- issue_conversion_warnings, c_cast_p, complain);
- if (expr == error_mark_node)
- return error_mark_node;
- return conv_expr ? conv_expr : expr;
-}
+/* We call this recursively in convert_like_internal. */
+static tree convert_like (conversion *, tree, tree, int, bool, bool,
+ tsubst_flags_t);
/* Perform the conversions in CONVS on the expression EXPR. FN and
ARGNUM are used for diagnostics. ARGNUM is zero based, -1
conversions to inaccessible bases are permitted. */
static tree
-convert_like_real_1 (conversion *convs, tree expr, tree fn, int argnum,
- bool issue_conversion_warnings,
- bool c_cast_p, tsubst_flags_t complain)
+convert_like_internal (conversion *convs, tree expr, tree fn, int argnum,
+ bool issue_conversion_warnings, bool c_cast_p,
+ tsubst_flags_t complain)
{
tree totype = convs->type;
diagnostic_t diag_kind;
totype);
if (complained)
print_z_candidate (loc, N_("candidate is:"), t->cand);
- expr = convert_like_real (t, expr, fn, argnum,
- /*issue_conversion_warnings=*/false,
- /*c_cast_p=*/false,
- complain);
+ expr = convert_like (t, expr, fn, argnum,
+ /*issue_conversion_warnings=*/false,
+ /*c_cast_p=*/false, complain);
if (convs->kind == ck_ref_bind)
expr = convert_to_reference (totype, expr, CONV_IMPLICIT,
LOOKUP_NORMAL, NULL_TREE,
}
else if (t->kind == ck_user || !t->bad_p)
{
- expr = convert_like_real (t, expr, fn, argnum,
- /*issue_conversion_warnings=*/false,
- /*c_cast_p=*/false,
- complain);
+ expr = convert_like (t, expr, fn, argnum,
+ /*issue_conversion_warnings=*/false,
+ /*c_cast_p=*/false, complain);
break;
}
else if (t->kind == ck_ambig)
- return convert_like_real (t, expr, fn, argnum,
- /*issue_conversion_warnings=*/false,
- /*c_cast_p=*/false,
- complain);
+ return convert_like (t, expr, fn, argnum,
+ /*issue_conversion_warnings=*/false,
+ /*c_cast_p=*/false, complain);
else if (t->kind == ck_identity)
break;
}
/* Convert all the elements. */
FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (expr), ix, val)
{
- tree sub = convert_like_real (convs->u.list[ix], val, fn,
- argnum, false, false, complain);
+ tree sub = convert_like (convs->u.list[ix], val, fn,
+ argnum, false, false, complain);
if (sub == error_mark_node)
return sub;
if (!BRACE_ENCLOSED_INITIALIZER_P (val)
break;
};
- expr = convert_like_real (next_conversion (convs), expr, fn, argnum,
- convs->kind == ck_ref_bind
- ? issue_conversion_warnings : false,
- c_cast_p, complain);
+ expr = convert_like (next_conversion (convs), expr, fn, argnum,
+ convs->kind == ck_ref_bind
+ ? issue_conversion_warnings : false,
+ c_cast_p, complain);
if (expr == error_mark_node)
return error_mark_node;
return expr;
}
+/* Wrapper for convert_like_internal that handles creating
+ IMPLICIT_CONV_EXPR. */
+
+static tree
+convert_like (conversion *convs, tree expr, tree fn, int argnum,
+ bool issue_conversion_warnings, bool c_cast_p,
+ tsubst_flags_t complain)
+{
+ /* Creating &TARGET_EXPR<> in a template breaks when substituting,
+ and creating a CALL_EXPR in a template breaks in finish_call_expr
+ so use an IMPLICIT_CONV_EXPR for this conversion. We would have
+ created such codes e.g. when calling a user-defined conversion
+ function. */
+ tree conv_expr = NULL_TREE;
+ if (processing_template_decl
+ && convs->kind != ck_identity
+ && (CLASS_TYPE_P (convs->type) || CLASS_TYPE_P (TREE_TYPE (expr))))
+ {
+ conv_expr = build1 (IMPLICIT_CONV_EXPR, convs->type, expr);
+ if (convs->kind != ck_ref_bind)
+ conv_expr = convert_from_reference (conv_expr);
+ if (!convs->bad_p)
+ return conv_expr;
+ /* Do the normal processing to give the bad_p errors. But we still
+ need to return the IMPLICIT_CONV_EXPR, unless we're returning
+ error_mark_node. */
+ }
+ expr = convert_like_internal (convs, expr, fn, argnum,
+ issue_conversion_warnings, c_cast_p, complain);
+ if (expr == error_mark_node)
+ return error_mark_node;
+ return conv_expr ? conv_expr : expr;
+}
+
+/* Convenience wrapper for convert_like. */
+
+static inline tree
+convert_like (conversion *convs, tree expr, tsubst_flags_t complain)
+{
+ return convert_like (convs, expr, NULL_TREE, 0,
+ /*issue_conversion_warnings=*/true,
+ /*c_cast_p=*/false, complain);
+}
+
+/* Convenience wrapper for convert_like. */
+
+static inline tree
+convert_like_with_context (conversion *convs, tree expr, tree fn, int argnum,
+ tsubst_flags_t complain)
+{
+ return convert_like (convs, expr, fn, argnum,
+ /*issue_conversion_warnings=*/true,
+ /*c_cast_p=*/false, complain);
+}
+
/* ARG is being passed to a varargs function. Perform any conversions
required. Return the converted value. */
IMPLICIT_CONV_EXPR_DIRECT_INIT (expr) = true;
}
else
- expr = convert_like_real (conv, expr, NULL_TREE, 0,
- /*issue_conversion_warnings=*/false,
- c_cast_p,
- complain);
+ expr = convert_like (conv, expr, NULL_TREE, 0,
+ /*issue_conversion_warnings=*/false,
+ c_cast_p, complain);
/* Free all the conversions we allocated. */
obstack_free (&conversion_obstack, p);