This test crashes with -fopenmp -freflection because consteval_only_p
gets
<omp_clause 0x7fffe99db120
type <tree_vec 0x7fffe982b900 length:3>
reduction
op-0: <var_decl 0x7fffe99d6390 acc>
op-1: <init_expr 0x7fffe99c9870>
op-2: <bind_expr 0x7fffe982b8a0>
op-3: <var_decl 0x7fffe99d6428 D.2864>
op-4:>
so it takes its type, but complete_type crashes on a TREE_VEC.
So let's handle TREE_VEC in consteval_only_p.
PR c++/124227
gcc/cp/ChangeLog:
* reflect.cc (consteval_only_p): Handle TREE_VEC.
gcc/testsuite/ChangeLog:
* g++.dg/reflect/pr124227.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
if (!t)
return false;
+ if (TREE_CODE (t) == TREE_VEC)
+ {
+ for (tree arg : tree_vec_range (t))
+ if (arg && consteval_only_p (arg))
+ return true;
+ return false;
+ }
+
/* We need the complete type otherwise we'd have no fields for class
templates and thus come up with zilch for things like
template<typename T>
--- /dev/null
+// PR c++/124227
+// { dg-do compile { target c++26 } }
+// { dg-additional-options "-freflection -fopenmp" }
+// { dg-require-effective-target fopenmp }
+
+using b = float;
+template <typename> class c {};
+#pragma omp declare reduction(d : c<float> : omp_in)
+auto e = [] {
+c<b> acc;
+#pragma omp parallel reduction(d : acc)
+{
+}
+};
+