Hi!
In r236630 we started using VCE for vector indexing, but
* expr.c (mark_exp_read): Handle VIEW_CONVERT_EXPR.
has been changed in C++ FE only, not C FE, while it is needed
in C FE too as the following testcase shows.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2016-07-01 Jakub Jelinek <[email protected]>
PR c/71719
* c-typeck.c (mark_exp_read): Handle VIEW_CONVERT_EXPR.
* c-c++-common/Wunused-var-15.c: New test.
--- gcc/c/c-typeck.c.jj 2016-06-29 16:10:29.000000000 +0200
+++ gcc/c/c-typeck.c 2016-07-01 16:30:55.756545761 +0200
@@ -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:
--- gcc/testsuite/c-c++-common/Wunused-var-15.c.jj 2016-07-01
16:39:39.639921566 +0200
+++ gcc/testsuite/c-c++-common/Wunused-var-15.c 2016-07-01 16:38:59.000000000
+0200
@@ -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.*" } */
Jakub