This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Fix -Wunused-but-set-* false positive with ~ of vector type (PR c++/78949)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 29 Dec 2016 16:19:28 +0100
- Subject: [C++ PATCH] Fix -Wunused-but-set-* false positive with ~ of vector type (PR c++/78949)
- Authentication-results: sourceware.org; auth=none
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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