Skip to content

Commit a284fad

Browse files
committed
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 <[email protected]> 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.
1 parent cc378e6 commit a284fad

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

gcc/cp/typeck.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6344,7 +6344,7 @@ build_x_shufflevector (location_t loc, vec<tree, va_gc> *args,
63446344
auto_vec<tree, 16> mask;
63456345
for (unsigned i = 2; i < args->length (); ++i)
63466346
{
6347-
tree idx = maybe_constant_value ((*args)[i]);
6347+
tree idx = fold_non_dependent_expr ((*args)[i], complain);
63486348
mask.safe_push (idx);
63496349
}
63506350
tree exp = c_build_shufflevector (loc, arg0, arg1, mask, complain & tf_error);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

0 commit comments

Comments
 (0)