A small improvement for an error in build_user_type_conversion_1:
instead of
array-init1.C:11:1: error: conversion from ‘long int’ to ‘A’ is ambiguous
11 | };
| ^
we will print
array-init1.C:8:3: error: conversion from ‘long int’ to ‘A’ is ambiguous
8 | 0L,
| ^~
2020-02-12 Marek Polacek <polacek@redhat.com>
PR c++/93710 - poor diagnostic for array initializer.
* call.c (build_user_type_conversion_1): Use cp_expr_loc_or_input_loc
for an error call.
* g++.dg/diagnostic/array-init1.C: New test.
+2020-02-15 Marek Polacek <polacek@redhat.com>
+
+ PR c++/93710 - poor diagnostic for array initializer.
+ * call.c (build_user_type_conversion_1): Use cp_expr_loc_or_input_loc
+ for an error call.
+
2020-02-15 Jason Merrill <jason@redhat.com>
PR c++/92556
if (complain & tf_error)
{
auto_diagnostic_group d;
- error ("conversion from %qH to %qI is ambiguous",
- fromtype, totype);
+ error_at (cp_expr_loc_or_input_loc (expr),
+ "conversion from %qH to %qI is ambiguous",
+ fromtype, totype);
print_z_candidates (location_of (expr), candidates);
}
+2020-02-15 Marek Polacek <polacek@redhat.com>
+
+ PR c++/93710 - poor diagnostic for array initializer.
+ * g++.dg/diagnostic/array-init1.C: New test.
+
2020-02-15 Jason Merrill <jason@redhat.com>
* lib/target-supports.exp (check_effective_target_c++2a_only): Also
--- /dev/null
+// PR c++/93710 - poor diagnostic for array initializer.
+
+struct A { A (int); A (char*); int i; };
+
+int x;
+
+A a1[] = {
+ 0L, // { dg-error "3:conversion from .long int. to .A. is ambiguous" }
+ &x, // { dg-error "3:invalid conversion from .int\\*. to .int." }
+ __builtin_offsetof (A, i) // { dg-error "23:conversion from .long unsigned int. to .A. is ambiguous" }
+};