From abec4284a64b3ebc6f986b5223a3623e682ae348 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 4 Jan 2017 22:34:27 +0100 Subject: [PATCH] re PR c++/78949 (incorrect "unused variable" warning with SSE2) 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: r244075 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/typeck.c | 2 ++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/c-c++-common/Wunused-var-16.c | 15 +++++++++++++++ 4 files changed, 24 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/Wunused-var-16.c diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 833b9049ee4..8dc6588ec31 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2017-01-04 Jakub Jelinek + PR c++/78949 + * typeck.c (cp_build_unary_op): Call mark_rvalue_use on arg if it has + vector type. + PR c++/78693 * parser.c (cp_parser_simple_declaration): Only complain about inconsistent auto deduction if auto_result doesn't use auto. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 57a69efb81e..6da98f65bdd 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5907,6 +5907,8 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert, 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: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index abdb8bb5a7e..f56c11b957f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2017-01-04 Jakub Jelinek + PR c++/78949 + * c-c++-common/Wunused-var-16.c: New test. + PR c++/78693 * g++.dg/cpp0x/pr78693.C: New test. 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 index 00000000000..98e66a72380 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wunused-var-16.c @@ -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; +} -- 2.30.2