[09/16] OpenMP: Allow array ref components for C & C++

Message ID 20211125140843.111405-5-julian@codesourcery.com
State New
Headers
Series OpenMP: lvalues in "map" clauses and struct handling rework |

Commit Message

Julian Brown Nov. 25, 2021, 2:08 p.m. UTC
  This patch fixes parsing for struct components that are array references
in OMP clauses in both the C and C++ front ends.

OK?

Thanks,

Julian

2021-09-29  Julian Brown  <julian@codesourcery.com>

gcc/c/
	* c-typeck.c (c_finish_omp_clauses): Allow ARRAY_REF components.

gcc/cp/
	* semantics.c (finish_omp_clauses): Allow ARRAY_REF components.
---
 gcc/c/c-typeck.c   | 3 ++-
 gcc/cp/semantics.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
  

Patch

diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index ee6362d4274..4d156f6d3ec 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -14918,7 +14918,8 @@  c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
 			{
 			  t = TREE_OPERAND (t, 0);
 			  if (TREE_CODE (t) == MEM_REF
-			      || TREE_CODE (t) == INDIRECT_REF)
+			      || TREE_CODE (t) == INDIRECT_REF
+			      || TREE_CODE (t) == ARRAY_REF)
 			    {
 			      t = TREE_OPERAND (t, 0);
 			      STRIP_NOPS (t);
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 50f95751d1c..e882c302f31 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -7910,7 +7910,8 @@  finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
 			  if (REFERENCE_REF_P (t))
 			    t = TREE_OPERAND (t, 0);
 			  if (TREE_CODE (t) == MEM_REF
-			      || TREE_CODE (t) == INDIRECT_REF)
+			      || TREE_CODE (t) == INDIRECT_REF
+			      || TREE_CODE (t) == ARRAY_REF)
 			    {
 			      t = TREE_OPERAND (t, 0);
 			      STRIP_NOPS (t);