diff options
author | Jakub Jelinek <jakub@redhat.com> | 2022-06-17 17:40:49 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2022-06-19 12:08:35 +0200 |
commit | 566e599c8194f789b077eb94a5e45ced2de5b31e (patch) | |
tree | 6bfb9d87edd07a1a3289f8e5132a6096a1d69128 | |
parent | expand: Fix up IFN_ATOMIC_{BIT*,*CMP_0} expansion [PR105951] (diff) | |
download | gcc-566e599c8194f789b077eb94a5e45ced2de5b31e.tar.gz gcc-566e599c8194f789b077eb94a5e45ced2de5b31e.tar.bz2 gcc-566e599c8194f789b077eb94a5e45ced2de5b31e.tar.xz |
c++: Use fold_non_dependent_expr rather than maybe_constant_value in __builtin_shufflevector handling [PR106001]
In this case the STATIC_CAST_EXPR expressions in the call aren't
type nor value dependent, but maybe_constant_value still ICEs on those
when processing_template_decl. Calling fold_non_dependent_expr on it
instead fixes the ICE and folds them to INTEGER_CSTs.
2022-06-17 Jakub Jelinek <jakub@redhat.com>
PR c++/106001
* typeck.cc (build_x_shufflevector): Use fold_non_dependent_expr
instead of maybe_constant_value.
* g++.dg/ext/builtin-shufflevector-4.C: New test.
(cherry picked from commit a284fadcce8ef443cc3cc047a8017745efb51758)
-rw-r--r-- | gcc/cp/typeck.cc | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/builtin-shufflevector-4.C | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc index a6c393647b2..ceb80d9744f 100644 --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc | |||
@@ -6334,7 +6334,7 @@ build_x_shufflevector (location_t loc, vec<tree, va_gc> *args, | |||
6334 | auto_vec<tree, 16> mask; | 6334 | auto_vec<tree, 16> mask; |
6335 | for (unsigned i = 2; i < args->length (); ++i) | 6335 | for (unsigned i = 2; i < args->length (); ++i) |
6336 | { | 6336 | { |
6337 | tree idx = maybe_constant_value ((*args)[i]); | 6337 | tree idx = fold_non_dependent_expr ((*args)[i], complain); |
6338 | mask.safe_push (idx); | 6338 | mask.safe_push (idx); |
6339 | } | 6339 | } |
6340 | tree exp = c_build_shufflevector (loc, arg0, arg1, mask, complain & tf_error); | 6340 | tree exp = c_build_shufflevector (loc, arg0, arg1, mask, complain & tf_error); |
diff --git a/gcc/testsuite/g++.dg/ext/builtin-shufflevector-4.C b/gcc/testsuite/g++.dg/ext/builtin-shufflevector-4.C new file mode 100644 index 00000000000..dae129b11d6 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/builtin-shufflevector-4.C | |||
@@ -0,0 +1,18 @@ | |||
1 | // PR c++/106001 | ||
2 | // { dg-do compile } | ||
3 | |||
4 | typedef int V __attribute__((vector_size (2 * sizeof (int)))); | ||
5 | |||
6 | template <int> | ||
7 | void | ||
8 | foo () | ||
9 | { | ||
10 | V v = {}; | ||
11 | v = __builtin_shufflevector (v, v, static_cast<char>(1), static_cast<char>(0)); | ||
12 | } | ||
13 | |||
14 | void | ||
15 | bar () | ||
16 | { | ||
17 | foo <0> (); | ||
18 | } | ||