re PR c/71719 (invalid set-but-not-used warning with vectors)
authorJakub Jelinek <jakub@redhat.com>
Sat, 2 Jul 2016 06:41:29 +0000 (08:41 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 2 Jul 2016 06:41:29 +0000 (08:41 +0200)
PR c/71719
* c-typeck.c (mark_exp_read): Handle VIEW_CONVERT_EXPR.

* c-c++-common/Wunused-var-15.c: New test.

From-SVN: r237937

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

index 7bd112b3bce6cbe25484e3d4fa211a76014dac8b..41d35470bed886406819ea26a0afdef52b6499a3 100644 (file)
@@ -1,3 +1,8 @@
+2016-07-02  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/71719
+       * c-typeck.c (mark_exp_read): Handle VIEW_CONVERT_EXPR.
+
 2016-06-29  Thomas Schwinge  <thomas@codesourcery.com>
 
        * c-parser.c (c_parser_pragma) <PRAGMA_OMP_CANCELLATION_POINT>:
index b2435deac067a0e5f40bdd61c8f2db7e070884a9..bafd0d23195bb9b2af9629f10d9a0f0857f9f0d1 100644 (file)
@@ -1896,6 +1896,7 @@ mark_exp_read (tree exp)
     case IMAGPART_EXPR:
     CASE_CONVERT:
     case ADDR_EXPR:
+    case VIEW_CONVERT_EXPR:
       mark_exp_read (TREE_OPERAND (exp, 0));
       break;
     case COMPOUND_EXPR:
index 08db9d19ed1d326d1f311128d61b12c3ca6ff85e..ced6ca7a7802dadfbd66e300087717a5c06f5ecb 100644 (file)
@@ -1,3 +1,8 @@
+2016-07-02  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/71719
+       * c-c++-common/Wunused-var-15.c: New test.
+
 2016-07-01  Jakub Jelinek  <jakub@redhat.com>
 
        PR fortran/71687
diff --git a/gcc/testsuite/c-c++-common/Wunused-var-15.c b/gcc/testsuite/c-c++-common/Wunused-var-15.c
new file mode 100644 (file)
index 0000000..b0f680a
--- /dev/null
@@ -0,0 +1,20 @@
+/* PR c/71719 */
+/* { dg-do compile } */
+/* { dg-options "-Wunused -W -Wno-psabi" } */
+
+typedef unsigned V __attribute__ ((vector_size (16)));
+
+void bar (unsigned);
+
+V x;
+
+void
+foo (V v)      /* { dg-bogus "set but not used" } */
+{
+  bar (v[0]);
+  V w = x;     /* { dg-bogus "set but not used" } */
+  bar (w[1]);
+}
+
+/* Ignore a warning that is irrelevant to the purpose of this test.  */
+/* { dg-prune-output ".*GCC vector passed by reference.*" } */