This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Avoid bogus -Wunused-but-set* with structured binding (PR c++/85952)


On Tue, May 29, 2018, 4:31 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> Initializing the decomposition temporary from an expression with array type
> is a special aggregate initialization path in which we wouldn't mark the
> expression as read for the purposes of -Wunused-but-set*.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
>
> 2018-05-29  Jakub Jelinek  <jakub@redhat.com>
>
>         PR c++/85952
>         * init.c (build_aggr_init): For structured binding initialized from
>         array call mark_rvalue_use on the initializer.
>
>         * g++.dg/warn/Wunused-var-33.C: New test.
>
> --- gcc/cp/init.c.jj    2018-05-25 14:34:41.000000000 +0200
> +++ gcc/cp/init.c       2018-05-28 19:04:10.504063972 +0200
> @@ -1678,6 +1678,7 @@ build_aggr_init (tree exp, tree init, in
>        if (VAR_P (exp) && DECL_DECOMPOSITION_P (exp))
>         {
>           from_array = 1;
> +         init = mark_rvalue_use (init);

This should be mark_lvalue_use, since the structured bindings refer to
the elements of the array rather than copying them.  OK with that
change.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]