From 5a8ad97b6e4823d4ded00a3ce8d80e4bf93368d4 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 5 Feb 2020 23:35:08 +0100 Subject: [PATCH] c++: Mark __builtin_convertvector operand as read [PR93557] In C++ we weren't calling mark_exp_read on the __builtin_convertvector first argument. I guess it could misbehave even with lambda implicit captures. Fixed by calling decay_conversion on the argument, we use the argument as rvalue so we want the standard lvalue to rvalue conversions, but as the argument must be a vector type, e.g. integral promotions aren't really needed. 2020-02-05 Jakub Jelinek PR c++/93557 * semantics.c (cp_build_vec_convert): Call decay_conversion on arg prior to passing it to c_build_vec_convert. * c-c++-common/Wunused-var-17.c: New test. --- gcc/ChangeLog | 6 ++++++ gcc/cp/semantics.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/c-c++-common/Wunused-var-17.c | 19 +++++++++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/c-c++-common/Wunused-var-17.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b986f2891f8..195cc9386fa 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2020-02-05 Jakub Jelinek + + PR c++/93557 + * semantics.c (cp_build_vec_convert): Call decay_conversion on arg + prior to passing it to c_build_vec_convert. + 2020-02-05 Michael Meissner PR target/93568 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 90f1e18e48a..2721a55c982 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -10389,7 +10389,8 @@ cp_build_vec_convert (tree arg, location_t loc, tree type, tree ret = NULL_TREE; if (!type_dependent_expression_p (arg) && !dependent_type_p (type)) - ret = c_build_vec_convert (cp_expr_loc_or_input_loc (arg), arg, + ret = c_build_vec_convert (cp_expr_loc_or_input_loc (arg), + decay_conversion (arg, complain), loc, type, (complain & tf_error) != 0); if (!processing_template_decl) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0a6513e666b..10021adc7e6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-02-05 Jakub Jelinek + + PR c++/93557 + * c-c++-common/Wunused-var-17.c: New test. + 2020-02-05 Jeff Law * gcc.target/hppa/shadd-3.c: Disable delay slot filling and diff --git a/gcc/testsuite/c-c++-common/Wunused-var-17.c b/gcc/testsuite/c-c++-common/Wunused-var-17.c new file mode 100644 index 00000000000..ab995f8b674 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wunused-var-17.c @@ -0,0 +1,19 @@ +/* PR c++/93557 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wunused-but-set-variable" } */ + +typedef int VI __attribute__((vector_size (sizeof (int) * 4))); +typedef float VF __attribute__((vector_size (sizeof (float) * 4))); + +void +foo (VI *p, VF *q) +{ + VI a = (VI) { 1, 2, 3, 4 }; /* { dg-bogus "set but not used" } */ + q[0] = __builtin_convertvector (a, VF); + VI b = p[1]; /* { dg-bogus "set but not used" } */ + q[1] = __builtin_convertvector (b, VF); + VF c = (VF) { 5.0f, 6.0f, 7.0f, 8.0f }; /* { dg-bogus "set but not used" } */ + p[2] = __builtin_convertvector (c, VI); + VF d = q[3]; /* { dg-bogus "set but not used" } */ + p[3] = __builtin_convertvector (d, VI); +} -- 2.30.2