@@ -17538,6 +17538,8 @@ tsubst_omp_clause_decl (tree decl, tree
*tp = copy_node (it);
TREE_VEC_ELT (*tp, 0)
= tsubst_decl (TREE_VEC_ELT (it, 0), args, complain);
+ DECL_CONTEXT (TREE_VEC_ELT (*tp, 0)) = current_function_decl;
+ pushdecl (TREE_VEC_ELT (*tp, 0));
TREE_VEC_ELT (*tp, 1)
= tsubst_expr (TREE_VEC_ELT (it, 1), args, complain, in_decl,
/*integral_constant_expression_p=*/false);
@@ -0,0 +1,26 @@
+// PR c++/105092
+// { dg-do compile { target analyzer } }
+// { dg-options "-fanalyzer -fopenmp" }
+
+struct S { S () {} };
+
+template <typename T>
+struct U {
+ T c[10];
+ U () {
+#pragma omp task affinity (iterator (i = 0 : 10 : 1): c[i])
+ ;
+ }
+};
+
+template <typename T>
+struct V {
+ T c[10];
+ V () {
+#pragma omp task depend (iterator (i = 0 : 10 : 1), inout: c[i])
+ ;
+ }
+};
+
+U<S> u;
+V<S> v;