https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100859
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
WIP testcase:
struct S {
S () {}
};
struct W {
S c[10];
W () {
#pragma omp task affinity (iterator (i = 0 : 10 : 1): c[i])
;
#pragma omp task depend (iterator (i = 0 : 10 : 1), inout: c[i])
;
#pragma omp task affinity (this[0])
;
#pragma omp task depend (inout: this[0])
;
#pragma omp taskwait
}
};
template <typename T>
struct U {
T c[10];
U () {
#pragma omp task affinity (iterator (i = 0 : 10 : 1): c[i])
;
#pragma omp task depend (iterator (i = 0 : 10 : 1), inout: c[i])
;
#pragma omp task affinity (this[0])
;
#pragma omp task depend (inout: this[0])
;
#pragma omp taskwait
}
};
struct V : public U<S> {
V () : U<S> () {}
};
W w;
V v;
and WIP patch:
--- gcc/cp/semantics.c.jj 2021-06-02 10:07:47.633826543 +0200
+++ gcc/cp/semantics.c 2021-06-02 11:35:39.490212873 +0200
@@ -4968,7 +4968,11 @@ handle_omp_array_sections_1 (tree c, tre
if (REFERENCE_REF_P (t))
t = TREE_OPERAND (t, 0);
}
- if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
+ if (TREE_CODE (t) == FIELD_DECL
+ && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND))
+ ret = finish_non_static_data_member (t, NULL_TREE, NULL_TREE);
+ else if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
{
if (processing_template_decl && TREE_CODE (t) != OVERLOAD)
return NULL_TREE;
@@ -4985,7 +4989,9 @@ handle_omp_array_sections_1 (tree c, tre
else if (ort == C_ORT_OMP
&& TREE_CODE (t) == PARM_DECL
&& DECL_ARTIFICIAL (t)
- && DECL_NAME (t) == this_identifier)
+ && DECL_NAME (t) == this_identifier
+ && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
+ && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND)
{
error_at (OMP_CLAUSE_LOCATION (c),
"%<this%> allowed in OpenMP only in %<declare simd%>"
@@ -7468,7 +7474,6 @@ finish_omp_clauses (tree clauses, enum c
}
goto handle_field_decl;
- case OMP_CLAUSE_AFFINITY:
case OMP_CLAUSE_DEPEND:
t = OMP_CLAUSE_DECL (c);
if (t == NULL_TREE)
@@ -7477,13 +7482,15 @@ finish_omp_clauses (tree clauses, enum c
== OMP_CLAUSE_DEPEND_SOURCE);
break;
}
- if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
- && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SINK)
+ if (OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SINK)
{
if (cp_finish_omp_clause_depend_sink (c))
remove = true;
break;
}
+ /* FALLTHRU */
+ case OMP_CLAUSE_AFFINITY:
+ t = OMP_CLAUSE_DECL (c);
if (TREE_CODE (t) == TREE_LIST
&& TREE_PURPOSE (t)
&& TREE_CODE (TREE_PURPOSE (t)) == TREE_VEC)
@@ -7543,11 +7550,9 @@ finish_omp_clauses (tree clauses, enum c
&& TREE_CODE (TREE_OPERAND (t, 1)) == FIELD_DECL
&& DECL_BIT_FIELD (TREE_OPERAND (t, 1)))
{
- gcc_assert (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
- || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY);
error_at (OMP_CLAUSE_LOCATION (c),
"bit-field %qE in %qs clause", t,
- omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
+ omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
remove = true;
}
else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
--- gcc/cp/pt.c.jj 2021-05-31 10:11:15.149978907 +0200
+++ gcc/cp/pt.c 2021-06-02 10:41:31.319178655 +0200
@@ -17399,6 +17399,7 @@ tsubst_omp_clauses (tree clauses, enum c
case OMP_CLAUSE_COPYPRIVATE:
case OMP_CLAUSE_UNIFORM:
case OMP_CLAUSE_DEPEND:
+ case OMP_CLAUSE_AFFINITY:
case OMP_CLAUSE_FROM:
case OMP_CLAUSE_TO:
case OMP_CLAUSE_MAP:
There are still ICEs on it though (on the non-template case).