c++: Fix poor diagnostic for array initializer [PR93710]
authorMarek Polacek <polacek@redhat.com>
Wed, 12 Feb 2020 19:00:51 +0000 (14:00 -0500)
committerMarek Polacek <polacek@redhat.com>
Sat, 15 Feb 2020 23:43:45 +0000 (17:43 -0600)
commiteef65c474e6836cc0470eb84f28895050161fcb8
tree53b5542b1bb39cda1c59521441faf88761b3d80f
parentfb26050409473f5be54465beca114b7e48de43aa
c++: Fix poor diagnostic for array initializer [PR93710]

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.
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/diagnostic/array-init1.C [new file with mode: 0644]