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  <ja...@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

Reply via email to