This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] Fix -Wunused-but-set-* false positive with ~ of vector type (PR c++/78949)
- 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: Wed, 4 Jan 2017 16:26:01 -0500
- Subject: Re: [C++ PATCH] Fix -Wunused-but-set-* false positive with ~ of vector type (PR c++/78949)
- Authentication-results: sourceware.org; auth=none
- References: <20161229151928.GP21933@tucnak>
OK.
On Thu, Dec 29, 2016 at 10:19 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> For integral arg, mark_exp_read is called during
> cp_perform_integral_promotions, for complex type it is called during
> cp_default_conversion, but for vector types nothing actually calls it.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
>
> 2016-12-29 Jakub Jelinek <jakub@redhat.com>
>
> PR c++/78949
> * typeck.c (cp_build_unary_op): Call mark_rvalue_use on arg if it has
> vector type.
>
> * c-c++-common/Wunused-var-16.c: New test.
>
> --- gcc/cp/typeck.c.jj 2016-12-21 23:12:01.000000000 +0100
> +++ gcc/cp/typeck.c 2016-12-29 13:48:58.363469890 +0100
> @@ -5907,6 +5907,8 @@ cp_build_unary_op (enum tree_code code,
> inform (location, "did you mean to use logical not (%<!%>)?");
> arg = cp_perform_integral_promotions (arg, complain);
> }
> + else if (!noconvert && VECTOR_TYPE_P (TREE_TYPE (arg)))
> + arg = mark_rvalue_use (arg);
> break;
>
> case ABS_EXPR:
> --- gcc/testsuite/c-c++-common/Wunused-var-16.c.jj 2016-12-29 13:51:07.143825569 +0100
> +++ gcc/testsuite/c-c++-common/Wunused-var-16.c 2016-12-29 13:50:42.000000000 +0100
> @@ -0,0 +1,15 @@
> +/* PR c++/78949 */
> +/* { dg-do compile } */
> +/* { dg-options "-Wunused" } */
> +
> +typedef unsigned char V __attribute__((vector_size(16)));
> +V v;
> +
> +void
> +foo ()
> +{
> + V y = {};
> + V x = {}; // { dg-bogus "set but not used" }
> + y &= ~x;
> + v = y;
> +}
>
> Jakub