{
if (hi != ohi)
{
- /* Work around maybe_convert_nontype_argument not doing this for
- dependent arguments. Don't use IMPLICIT_CONV_EXPR_NONTYPE_ARG
- because that will make tsubst_expr ignore it. */
- tree type = tsubst (TREE_TYPE (ohi), args, complain, in_decl);
- if (!TREE_TYPE (hi) || !same_type_p (type, TREE_TYPE (hi)))
- hi = build1 (IMPLICIT_CONV_EXPR, type, hi);
-
call = copy_node (call);
CALL_EXPR_ARG (call, 0) = hi;
}
conversion for the benefit of cp_tree_equal. */
static tree
-maybe_convert_nontype_argument (tree type, tree arg)
+maybe_convert_nontype_argument (tree type, tree arg, bool force)
{
/* Auto parms get no conversion. */
if (type_uses_auto (type))
return arg;
+ /* ??? Do we need to push the IMPLICIT_CONV_EXPR into the pack expansion?
+ That would complicate other things, and it doesn't seem necessary. */
+ if (TREE_CODE (arg) == EXPR_PACK_EXPANSION)
+ return arg;
/* We don't need or want to add this conversion now if we're going to use the
argument for deduction. */
- if (value_dependent_expression_p (arg))
+ if (!value_dependent_expression_p (arg))
+ force = false;
+ else if (!force)
return arg;
type = cv_unqualified (type);
tree argtype = TREE_TYPE (arg);
- if (same_type_p (type, argtype))
+ if (argtype && same_type_p (type, argtype))
return arg;
arg = build1 (IMPLICIT_CONV_EXPR, type, arg);
IMPLICIT_CONV_EXPR_NONTYPE_ARG (arg) = true;
+ IMPLICIT_CONV_EXPR_FORCED (arg) = force;
return arg;
}
if (t != TREE_TYPE (parm))
t = canonicalize_type_argument (t, complain);
+ /* We need to handle arguments for alias or concept templates
+ differently: we need to force building an IMPLICIT_CONV_EXPR, because
+ these arguments are going to be substituted directly into the
+ dependent type; they might not get another chance at
+ convert_nontype_argument. But if the argument ends up here again for
+ a template that isn't one of those, remove the conversion for
+ consistency between naming the same dependent type directly or through
+ an alias. */
+ bool force_conv = in_decl && (DECL_ALIAS_TEMPLATE_P (in_decl)
+ || concept_definition_p (in_decl));
+ if (!force_conv
+ && TREE_CODE (orig_arg) == IMPLICIT_CONV_EXPR
+ && IMPLICIT_CONV_EXPR_FORCED (orig_arg)
+ && same_type_p (TREE_TYPE (orig_arg), t))
+ orig_arg = TREE_OPERAND (orig_arg, 0);
+
if (!type_dependent_expression_p (orig_arg)
&& !uses_template_parms (t))
/* We used to call digest_init here. However, digest_init
else
{
val = canonicalize_expr_argument (orig_arg, complain);
- val = maybe_convert_nontype_argument (t, val);
+ val = maybe_convert_nontype_argument (t, val, force_conv);
}
-
if (val == NULL_TREE)
val = error_mark_node;
else if (val == error_mark_node && (complain & tf_error))
RETURN (retval);
}
if (IMPLICIT_CONV_EXPR_NONTYPE_ARG (t))
- /* We'll pass this to convert_nontype_argument again, we don't need
- to actually perform any conversion here. */
- RETURN (expr);
+ {
+ tree r = convert_nontype_argument (type, expr, complain);
+ if (r == NULL_TREE)
+ r = error_mark_node;
+ RETURN (r);
+ }
int flags = LOOKUP_IMPLICIT;
if (IMPLICIT_CONV_EXPR_DIRECT_INIT (t))
flags = LOOKUP_NORMAL;