diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 8b492cf5bed..ac6618eca5c 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -14929,7 +14929,8 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) t = TREE_OPERAND (t, 0); } } - while (TREE_CODE (t) == COMPONENT_REF); + while (TREE_CODE (t) == COMPONENT_REF + || TREE_CODE (t) == ARRAY_REF); if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP && OMP_CLAUSE_MAP_IMPLICIT (c) diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 00100b0c080..089ea5f49bb 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -7942,7 +7942,8 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) t = TREE_OPERAND (t, 0); } } - while (TREE_CODE (t) == COMPONENT_REF); + while (TREE_CODE (t) == COMPONENT_REF + || TREE_CODE (t) == ARRAY_REF); if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP && OMP_CLAUSE_MAP_IMPLICIT (c) diff --git a/gcc/testsuite/c-c++-common/gomp/pr103705.c b/gcc/testsuite/c-c++-common/gomp/pr103705.c new file mode 100644 index 00000000000..bf4c7066d28 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr103705.c @@ -0,0 +1,14 @@ +/* PR c++/103705 */ +/* { dg-do compile } */ + +struct S +{ + int a[2]; +}; + +int main (void) +{ + struct S s[1]; + #pragma omp target update from(s[0].a[0:1]) + return 0; +}