From 557e8c49cf47555401cf07c020ebdf6ddd4296b5 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 2 Jul 2016 08:41:29 +0200 Subject: [PATCH] re PR c/71719 (invalid set-but-not-used warning with vectors) 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 | 5 +++++ gcc/c/c-typeck.c | 1 + gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/c-c++-common/Wunused-var-15.c | 20 ++++++++++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/Wunused-var-15.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 7bd112b3bce..41d35470bed 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2016-07-02 Jakub Jelinek + + PR c/71719 + * c-typeck.c (mark_exp_read): Handle VIEW_CONVERT_EXPR. + 2016-06-29 Thomas Schwinge * c-parser.c (c_parser_pragma) : diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index b2435deac06..bafd0d23195 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -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: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 08db9d19ed1..ced6ca7a780 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-07-02 Jakub Jelinek + + PR c/71719 + * c-c++-common/Wunused-var-15.c: New test. + 2016-07-01 Jakub Jelinek 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 index 00000000000..b0f680a06bd --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wunused-var-15.c @@ -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.*" } */ -- 2.30.2