name but the DECL_VALUE_EXPR will be dependent. Hide those
from folding of other loop initializers e.g. for warning
purposes until cp_finish_omp_range_for. */
- gcc_checking_assert (DECL_HAS_VALUE_EXPR_P (decomp_first_name));
+ gcc_checking_assert (DECL_HAS_VALUE_EXPR_P (decomp_first_name)
+ || (TREE_TYPE (decomp_first_name)
+ == error_mark_node));
DECL_HAS_VALUE_EXPR_P (decomp_first_name) = 0;
}
TREE_VEC_ELT (v, i + 3) = decomp_first_name;
tree d = decomp_first_name;
for (unsigned i = 0; i < decomp_cnt; i++)
{
- DECL_HAS_VALUE_EXPR_P (d) = 1;
+ if (TREE_TYPE (d) != error_mark_node)
+ DECL_HAS_VALUE_EXPR_P (d) = 1;
d = DECL_CHAIN (d);
}
}
--- /dev/null
+// PR c++/105839
+// { dg-do compile { target c++11 } }
+// { dg-options "-fopenmp" }
+
+template <typename T>
+void
+foo (const T &x)
+{
+ [&] (auto &&y) // { dg-error "use of 'auto' in lambda parameter declaration only available with" "" { target c++11_only } }
+ {
+ #pragma omp parallel for
+ for (auto &&[v1, v2] : x) // { dg-error "cannot decompose non-array non-class type 'const int'" }
+ ; // { dg-error "invalid type for iteration variable" "" { target c++14 } .-1 }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-2 }
+ } ([]{}); // { dg-error "no match for call to" "" { target c++11_only } }
+ // { dg-error "invalid user-defined conversion from" "" { target c++11_only } .-1 }
+ // { dg-error "invalid conversion from" "" { target c++11_only } .-2 }
+}
+
+void
+bar ()
+{
+ int a[10];
+ foo (a);
+}
--- /dev/null
+// PR c++/105839
+// { dg-do compile { target c++14 } }
+// { dg-options "-fopenmp" }
+
+template <typename T>
+void
+foo (const T &x)
+{
+ [&] (auto &&y)
+ {
+ #pragma omp parallel for
+ for (auto &&[v1, v2] : x) // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ ;
+ } ([]{});
+}
+
+struct A { int a, b; };
+
+void
+bar ()
+{
+ A a[10];
+ foo (a);
+}