On 11/29/18 10:22 AM, Paolo Carlini wrote:
Hi,
On 29/11/18 03:01, Jason Merrill wrote:
On 11/6/18 4:01 AM, Paolo Carlini wrote:
when I improved create_array_type_for_decl I didn't notice that it
calls compute_array_index_type as helper, which simply needs to have
the location information propagated. Tested x86_64-linux.
This looks like it will use the declarator-id location in diagnostics
about the array bound expression, which isn't optimal; if 'size' has a
location, we should use that instead.
Yes. The below, for all the error messages talking about "size", uses
the location of "size" and either the passed location or input_location
as fall-back. This, afaics, also matches the behavior of clang. There
are a few minor subtleties: 1- A first version of the patch didn't
exploit the location of "size" in the unnamed cases, but doing that
actually helps for testcases like the new constexpr-base6b.C; 2- It's
important to use the original "size" - as saved in "osize" - otherwise
after the folding the location information is lost in some cases (eg,
happens for the ubsan testcase and a couple of g++.old-deja tests); 3- I
didn't change the warnings about variable length arrays to exploit the
location of "size", because they don't explicitly talk about the size -
that, by the way, appears to match clang's behavior.
+ error_at (cp_expr_loc_or_loc (osize, loc),
....
+ error_at (cp_expr_loc_or_loc (osize, input_location),
Let's compute the location we want to use once at the top of the
function. And maybe rename the 'loc' parameter to name_loc.
Jason