diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc index 522b7c06a29..5254ac028d1 100644 --- a/gcc/cp/reflect.cc +++ b/gcc/cp/reflect.cc @@ -8086,6 +8086,14 @@ consteval_only_p (tree t) 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 diff --git a/gcc/testsuite/g++.dg/reflect/pr124227.C b/gcc/testsuite/g++.dg/reflect/pr124227.C new file mode 100644 index 00000000000..09e14043567 --- /dev/null +++ b/gcc/testsuite/g++.dg/reflect/pr124227.C @@ -0,0 +1,15 @@ +// PR c++/124227 +// { dg-do compile { target c++26 } } +// { dg-additional-options "-freflection -fopenmp" } +// { dg-require-effective-target fopenmp } + +using b = float; +template class c {}; +#pragma omp declare reduction(d : c : omp_in) +auto e = [] { +c acc; +#pragma omp parallel reduction(d : acc) +{ +} +}; +