This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] Fix error-recovery in compute_array_index_type (PR c++/85015)
- From: Jason Merrill <jason at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 23 Mar 2018 14:20:17 -0400
- Subject: Re: [C++ PATCH] Fix error-recovery in compute_array_index_type (PR c++/85015)
- References: <20180322212759.GV8577@tucnak> <CADzB+2=O5OBrdvFQ=1w49jWWh_b9sdsPFuJ9QuN1o3G-v4sW3A@mail.gmail.com> <20180323141707.GI8577@tucnak> <CADzB+2n97TdzhB5bg1yZ8BYM998FVUJWgB7VoYO2gRE325WbtA@mail.gmail.com> <20180323172601.GL8577@tucnak>
OK.
On Fri, Mar 23, 2018 at 1:26 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Fri, Mar 23, 2018 at 12:32:20PM -0400, Jason Merrill wrote:
>> > 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.
>
> Yes, at least check-c++-all doesn't regress with this, will do now full
> bootstrap/regtest. Ok if it passes?
>
> 2018-03-23 Jakub Jelinek <jakub@redhat.com>
>
> PR c++/85015
> * decl.c (compute_array_index_type): 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 17:33:52.412071232 +0100
> @@ -9520,7 +9520,7 @@ compute_array_index_type (tree name, tre
>
> if (!type_dependent_expression_p (size))
> {
> - size = mark_rvalue_use (size);
> + osize = size = mark_rvalue_use (size);
>
> if (cxx_dialect < cxx11 && TREE_CODE (size) == NOP_EXPR
> && TREE_SIDE_EFFECTS (size))
> --- gcc/testsuite/g++.dg/cpp0x/pr85015.C.jj 2018-03-23 14:51:19.207892516 +0100
> +++ gcc/testsuite/g++.dg/cpp0x/pr85015.C 2018-03-23 14:51:19.207892516 +0100
> @@ -0,0 +1,12 @@
> +// PR c++/85015
> +// { dg-do compile { target c++11 } }
> +// { dg-options "" }
> +
> +void
> +foo ()
> +{
> + int &&c = v + 1; // { dg-error "was not declared in this scope" }
> + struct S { // { dg-message "declared here" "" { target *-*-* } .-1 }
> + void bar () { int a[c]; } // { dg-error "use of local variable with automatic storage from containing function" }
> + } e;
> +}
>
>
> Jakub