+2020-02-24 Marek Polacek <polacek@redhat.com>
+
+ PR c++/93712 - ICE with ill-formed array list-initialization.
+ * call.c (next_conversion): Return NULL for ck_aggr.
+ (build_aggr_conv): Set u.expr instead of u.next.
+ (build_array_conv): Likewise.
+ (build_complex_conv): Likewise.
+ (conv_get_original_expr): Handle ck_aggr.
+
2020-02-24 Jakub Jelinek <jakub@redhat.com>
P1937R2 - Fixing inconsistencies between const{expr,eval} functions
/* The next conversion in the chain. Since the conversions are
arranged from outermost to innermost, the NEXT conversion will
actually be performed before this conversion. This variant is
- used only when KIND is neither ck_identity, ck_ambig nor
+ used only when KIND is neither ck_identity, ck_aggr, ck_ambig nor
ck_list. Please use the next_conversion function instead
of using this field directly. */
conversion *next;
/* The expression at the beginning of the conversion chain. This
- variant is used only if KIND is ck_identity or ck_ambig. You can
- use conv_get_original_expr to get this expression. */
+ variant is used only if KIND is ck_identity, ck_aggr, or ck_ambig.
+ You can use conv_get_original_expr to get this expression. */
tree expr;
/* The array of conversions for an initializer_list, so this
variant is used only when KIN D is ck_list. */
if (conv == NULL
|| conv->kind == ck_identity
|| conv->kind == ck_ambig
- || conv->kind == ck_list)
+ || conv->kind == ck_list
+ || conv->kind == ck_aggr)
return NULL;
return conv->u.next;
}
c->rank = cr_exact;
c->user_conv_p = true;
c->check_narrowing = true;
- c->u.next = NULL;
+ c->u.expr = ctor;
return c;
}
c->rank = rank;
c->user_conv_p = user;
c->bad_p = bad;
- c->u.next = build_identity_conv (TREE_TYPE (ctor), ctor);
+ c->u.expr = ctor;
return c;
}
c->rank = rank;
c->user_conv_p = user;
c->bad_p = bad;
- c->u.next = NULL;
+ c->u.expr = ctor;
return c;
}
conv_get_original_expr (conversion *c)
{
for (; c; c = next_conversion (c))
- if (c->kind == ck_identity || c->kind == ck_ambig)
+ if (c->kind == ck_identity || c->kind == ck_ambig || c->kind == ck_aggr)
return c->u.expr;
return NULL_TREE;
}
--- /dev/null
+// PR c++/93712 - ICE with ill-formed array list-initialization.
+// { dg-do compile { target c++11 } }
+
+int f (const int (&)[2]);
+
+int g ()
+{
+ const int (&r)[2] = {1, "foo"}; // { dg-error "conversion" }
+ return f({1, "foo"}); // { dg-error "conversion" }
+}