]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/78949 (incorrect "unused variable" warning with SSE2)
authorJakub Jelinek <jakub@redhat.com>
Tue, 30 May 2017 07:53:35 +0000 (09:53 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 30 May 2017 07:53:35 +0000 (09:53 +0200)
Backported from mainline
2017-01-04  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.

From-SVN: r248637

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/Wunused-var-16.c [new file with mode: 0644]

index b0fbf05a999669a5215d9fc88e0c15cda6fc52d8..52a1d0e5b906c3cf52c9a327d2044fe34ea8bad3 100644 (file)
@@ -1,6 +1,12 @@
 2017-05-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-01-04  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.
+
        2016-12-02  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/78649
index 669f54141387128d3c2114a8191d2c24caebdcb2..e3ba6077c09e1a7dacd49b68830eb415c01167a6 100644 (file)
@@ -5700,6 +5700,8 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert,
        errstring = _("wrong type argument to bit-complement");
       else if (!noconvert && CP_INTEGRAL_TYPE_P (TREE_TYPE (arg)))
        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:
index 51e63c6bd2a374e0ab8036e41177393d48a4bcae..9424d657d5075f75c21487c51cca1ce0f731bd39 100644 (file)
@@ -1,6 +1,11 @@
 2017-05-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-01-04  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/78949
+       * c-c++-common/Wunused-var-16.c: New test.
+
        2016-12-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR fortran/78866
diff --git a/gcc/testsuite/c-c++-common/Wunused-var-16.c b/gcc/testsuite/c-c++-common/Wunused-var-16.c
new file mode 100644 (file)
index 0000000..98e66a7
--- /dev/null
@@ -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;
+}