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 *args, auto_vec mask; for (unsigned i = 2; i < args->length (); ++i) { - tree idx = maybe_constant_value ((*args)[i]); + tree idx = fold_non_dependent_expr ((*args)[i], complain); mask.safe_push (idx); } 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 @@ +// PR c++/106001 +// { dg-do compile } + +typedef int V __attribute__((vector_size (2 * sizeof (int)))); + +template +void +foo () +{ + V v = {}; + v = __builtin_shufflevector (v, v, static_cast(1), static_cast(0)); +} + +void +bar () +{ + foo <0> (); +}