]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Mark __builtin_convertvector operand as read [PR93557]
authorJakub Jelinek <jakub@redhat.com>
Wed, 5 Feb 2020 22:35:08 +0000 (23:35 +0100)
committerJakub Jelinek <jakub@redhat.com>
Thu, 13 Feb 2020 20:42:32 +0000 (21:42 +0100)
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  <jakub@redhat.com>

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/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/Wunused-var-17.c [new file with mode: 0644]

index 31dee033f6eac8fdd28134ce07c9820ae1fd1f88..d9bb3b5d75b4d6ffdec44e29621f85248fc602c5 100644 (file)
@@ -1,6 +1,12 @@
 2020-02-13  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2020-02-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/93557
+       * semantics.c (cp_build_vec_convert): Call decay_conversion on arg
+       prior to passing it to c_build_vec_convert.
+
        2020-01-29  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/91118
index 1bd014696fcdcd4a41b97017e261c3d230c4dbe6..0c727eaf2e733d69784f704a8226d58459fb16cb 100644 (file)
@@ -10036,7 +10036,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_loc (arg, input_location), arg,
+    ret = c_build_vec_convert (cp_expr_loc_or_loc (arg, input_location),
+                              decay_conversion (arg, complain),
                               loc, type, (complain & tf_error) != 0);
 
   if (!processing_template_decl)
index 96390af9e1264dd46befd082f77d72623240613e..2cfc06f5605e25ba979a798ec564eede95e583d2 100644 (file)
@@ -3,6 +3,9 @@
        Backported from mainline
        2020-02-05  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/93557
+       * c-c++-common/Wunused-var-17.c: New test.
+
        PR middle-end/93555
        * c-c++-common/gomp/pr93555-1.c: New test.
        * c-c++-common/gomp/pr93555-2.c: New test.
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 (file)
index 0000000..ab995f8
--- /dev/null
@@ -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);
+}