[C++ PATCH] Fix error-recovery in compute_array_index_type (PR c++/85015)
Jason Merrill
jason@redhat.com
Fri Mar 23 16:34:00 GMT 2018
On Fri, Mar 23, 2018 at 10:17 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Fri, Mar 23, 2018 at 09:31:53AM -0400, Jason Merrill wrote:
>> On Thu, Mar 22, 2018 at 5:27 PM, Jakub Jelinek <jakub@redhat.com> wrote:
>> > We ICE during error-recovery on the following testcase, compute_array_index_type
>> > checks size for error_operand_p early (and it is not error operand; it is
>> > <indirect_ref <var_decl c>> where c is of reference type with
>> > error_mark_node DECL_INITIAL), then calls mark_rvalue_use (which returns error_mark_node), but we let it go
>> > through maybe_constant_size etc. and because error_mark_node is
>> > !TREE_CONSTANT, set it back to the original size.
>>
>> Hmm, maybe we need to also update osize with the result of
>> mark_rvalue_use. Or flip the logic of the constant value block to use
>> a local variable and only change size if the result is constant.
>
> Like this? Passes check-c++-all...
>
> 2018-03-23 Jakub Jelinek <jakub@redhat.com>
>
> PR c++/85015
> * decl.c (compute_array_index_type): Return error_mark_node if
> mark_rvalue_use or maybe_constant_value returns error_operand_p.
> Set osize to mark_rvalue_use result.
>
> * g++.dg/cpp0x/pr85015.C: New test.
>
> --- gcc/cp/decl.c.jj 2018-03-22 22:23:10.120015621 +0100
> +++ gcc/cp/decl.c 2018-03-23 14:52:07.274893996 +0100
> @@ -9520,7 +9520,10 @@ compute_array_index_type (tree name, tre
>
> if (!type_dependent_expression_p (size))
> {
> - size = mark_rvalue_use (size);
> + osize = size = mark_rvalue_use (size);
With this, I think we shouldn't need the other changes.
Jason
More information about the Gcc-patches
mailing list