https://gcc.gnu.org/g:61bc95e26db6fb58d98a119a04f433d5f14d9550

commit 61bc95e26db6fb58d98a119a04f433d5f14d9550
Author: Julian Brown <jul...@codesourcery.com>
Date:   Tue Apr 30 19:21:22 2024 +0200

    OpenMP: Allow complete replacement of clause during map/to/from expansion
    
    At present, map/to/from clauses on OpenMP "target" directives may be
    expanded into several mapping nodes if they describe array sections with
    pointer or reference bases, or similar.  This patch allows the original
    clause to be replaced during that expansion, mostly by passing the list
    pointer to the node to various functions rather than the node itself.
    
    This is needed by the following patch. There shouldn't be any functional
    changes introduced by this patch itself.
    
    2023-09-05  Julian Brown  <jul...@codesourcery.com>
    
    gcc/c-family/
            * c-common.h (expand_array_base, expand_component_selector,
            expand_map_clause): Adjust member declarations.
            * c-omp.cc (omp_expand_access_chain): Pass and return pointer to
            clause.
            (c_omp_address_inspector::expand_array_base): Likewise.
            (c_omp_address_inspector::expand_component_selector): Likewise.
            (c_omp_address_inspector::expand_map_clause): Likewise.
    
    gcc/c/
            * c-typeck.cc (handle_omp_array_sections): Pass pointer to clause to
            process instead of clause.
            (c_finish_omp_clauses): Update calls to handle_omp_array_sections.
            Handle cases where initial clause might be replaced.
    
    gcc/cp/
            * semantics.cc (handle_omp_array_sections): Pass pointer to clause
            instead of clause.  Add PNEXT return parameter for next clause in 
list
            to process.
            (finish_omp_clauses): Update calls to handle_omp_array_sections.
            Handle cases where initial clause might be replaced.

Diff:
---
 gcc/c-family/ChangeLog.omp | 10 +++++++
 gcc/c-family/c-common.h    | 12 ++++----
 gcc/c-family/c-omp.cc      | 75 ++++++++++++++++++++++++----------------------
 gcc/c/ChangeLog.omp        |  7 +++++
 gcc/c/c-typeck.cc          | 45 ++++++++++++++++++----------
 gcc/cp/ChangeLog.omp       |  8 +++++
 gcc/cp/semantics.cc        | 37 +++++++++++++++--------
 7 files changed, 123 insertions(+), 71 deletions(-)

diff --git a/gcc/c-family/ChangeLog.omp b/gcc/c-family/ChangeLog.omp
index 572315bd425..0b29e79e4a1 100644
--- a/gcc/c-family/ChangeLog.omp
+++ b/gcc/c-family/ChangeLog.omp
@@ -1,3 +1,13 @@
+2023-09-05  Julian Brown  <jul...@codesourcery.com>
+
+       * c-common.h (expand_array_base, expand_component_selector,
+       expand_map_clause): Adjust member declarations.
+       * c-omp.cc (omp_expand_access_chain): Pass and return pointer to
+       clause.
+       (c_omp_address_inspector::expand_array_base): Likewise.
+       (c_omp_address_inspector::expand_component_selector): Likewise.
+       (c_omp_address_inspector::expand_map_clause): Likewise.
+
 2023-08-10  Julian Brown  <jul...@codesourcery.com>
 
        * c-common.h (c_omp_region_type): Add C_ORT_DECLARE_MAPPER and
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 6ca9ffb2d6f..a6d372deaa2 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -1384,12 +1384,12 @@ public:
 
   bool maybe_zero_length_array_section (tree);
 
-  tree expand_array_base (tree, vec<omp_addr_token *> &, tree, unsigned *,
-                         c_omp_region_type);
-  tree expand_component_selector (tree, vec<omp_addr_token *> &, tree,
-                                 unsigned *, c_omp_region_type);
-  tree expand_map_clause (tree, tree, vec<omp_addr_token *> &,
-                         c_omp_region_type);
+  tree * expand_array_base (tree *, vec<omp_addr_token *> &, tree, unsigned *,
+                           c_omp_region_type);
+  tree * expand_component_selector (tree *, vec<omp_addr_token *> &, tree,
+                                   unsigned *, c_omp_region_type);
+  tree * expand_map_clause (tree *, tree, vec<omp_addr_token *> &,
+                           c_omp_region_type);
 };
 
 enum c_omp_directive_kind {
diff --git a/gcc/c-family/c-omp.cc b/gcc/c-family/c-omp.cc
index 390d6aecae4..f85b1db02ea 100644
--- a/gcc/c-family/c-omp.cc
+++ b/gcc/c-family/c-omp.cc
@@ -3620,11 +3620,12 @@ 
c_omp_address_inspector::maybe_zero_length_array_section (tree clause)
    expression types here, because e.g. you can't have an array of
    references.  */
 
-static tree
-omp_expand_access_chain (tree c, tree expr, vec<omp_addr_token *> &addr_tokens,
-                        unsigned *idx, c_omp_region_type ort)
+static tree *
+omp_expand_access_chain (tree *pc, tree expr,
+                        vec<omp_addr_token *> &addr_tokens, unsigned *idx, 
c_omp_region_type ort)
 {
   using namespace omp_addr_tokenizer;
+  tree c = *pc;
   location_t loc = OMP_CLAUSE_LOCATION (c);
   unsigned i = *idx;
   tree c2 = NULL_TREE;
@@ -3667,34 +3668,35 @@ omp_expand_access_chain (tree c, tree expr, 
vec<omp_addr_token *> &addr_tokens,
       break;
 
     default:
-      return error_mark_node;
+      return NULL;
     }
 
   if (c2)
     {
       OMP_CLAUSE_CHAIN (c2) = OMP_CLAUSE_CHAIN (c);
       OMP_CLAUSE_CHAIN (c) = c2;
-      c = c2;
+      pc = &OMP_CLAUSE_CHAIN (c);
     }
 
   *idx = ++i;
 
   if (i < addr_tokens.length ()
       && addr_tokens[i]->type == ACCESS_METHOD)
-    return omp_expand_access_chain (c, expr, addr_tokens, idx, ort);
+    return omp_expand_access_chain (pc, expr, addr_tokens, idx, ort);
 
-  return c;
+  return pc;
 }
 
 /* Translate "array_base_decl access_method" to OMP mapping clauses.  */
 
-tree
-c_omp_address_inspector::expand_array_base (tree c,
+tree *
+c_omp_address_inspector::expand_array_base (tree *pc,
                                            vec<omp_addr_token *> &addr_tokens,
                                            tree expr, unsigned *idx,
                                            c_omp_region_type ort)
 {
   using namespace omp_addr_tokenizer;
+  tree c = *pc;
   location_t loc = OMP_CLAUSE_LOCATION (c);
   int i = *idx;
   tree decl = addr_tokens[i + 1]->expr;
@@ -3720,7 +3722,7 @@ c_omp_address_inspector::expand_array_base (tree c,
     {
       i += 2;
       *idx = i;
-      return c;
+      return pc;
     }
 
   switch (addr_tokens[i + 1]->u.access_kind)
@@ -3997,7 +3999,7 @@ c_omp_address_inspector::expand_array_base (tree c,
 
     default:
       *idx = i + consume_tokens;
-      return error_mark_node;
+      return NULL;
     }
 
   if (c3)
@@ -4010,7 +4012,7 @@ c_omp_address_inspector::expand_array_base (tree c,
          OMP_CLAUSE_MAP_IMPLICIT (c2) = 1;
          OMP_CLAUSE_MAP_IMPLICIT (c3) = 1;
        }
-      c = c3;
+      pc = &OMP_CLAUSE_CHAIN (c2);
     }
   else if (c2)
     {
@@ -4018,28 +4020,29 @@ c_omp_address_inspector::expand_array_base (tree c,
       OMP_CLAUSE_CHAIN (c) = c2;
       if (implicit_p)
        OMP_CLAUSE_MAP_IMPLICIT (c2) = 1;
-      c = c2;
+      pc = &OMP_CLAUSE_CHAIN (c);
     }
 
   i += consume_tokens;
   *idx = i;
 
   if (chain_p && map_p)
-    return omp_expand_access_chain (c, expr, addr_tokens, idx, ort);
+    return omp_expand_access_chain (pc, expr, addr_tokens, idx, ort);
 
-  return c;
+  return pc;
 }
 
 /* Translate "component_selector access_method" to OMP mapping clauses.  */
 
-tree
-c_omp_address_inspector::expand_component_selector (tree c,
+tree *
+c_omp_address_inspector::expand_component_selector (tree *pc,
                                                    vec<omp_addr_token *>
                                                      &addr_tokens,
                                                    tree expr, unsigned *idx,
                                                    c_omp_region_type ort)
 {
   using namespace omp_addr_tokenizer;
+  tree c = *pc;
   location_t loc = OMP_CLAUSE_LOCATION (c);
   unsigned i = *idx;
   tree c2 = NULL_TREE, c3 = NULL_TREE;
@@ -4146,7 +4149,7 @@ c_omp_address_inspector::expand_component_selector (tree 
c,
 
     default:
       *idx = i + 2;
-      return error_mark_node;
+      return NULL;
     }
 
   if (c3)
@@ -4154,29 +4157,29 @@ c_omp_address_inspector::expand_component_selector 
(tree c,
       OMP_CLAUSE_CHAIN (c3) = OMP_CLAUSE_CHAIN (c);
       OMP_CLAUSE_CHAIN (c2) = c3;
       OMP_CLAUSE_CHAIN (c) = c2;
-      c = c3;
+      pc = &OMP_CLAUSE_CHAIN (c2);
     }
   else if (c2)
     {
       OMP_CLAUSE_CHAIN (c2) = OMP_CLAUSE_CHAIN (c);
       OMP_CLAUSE_CHAIN (c) = c2;
-      c = c2;
+      pc = &OMP_CLAUSE_CHAIN (c);
     }
 
   i += 2;
   *idx = i;
 
   if (chain_p && map_p)
-    return omp_expand_access_chain (c, expr, addr_tokens, idx, ort);
+    return omp_expand_access_chain (pc, expr, addr_tokens, idx, ort);
 
-  return c;
+  return pc;
 }
 
 /* Expand a map clause into a group of mapping clauses, creating nodes to
    attach/detach pointers and so forth as necessary.  */
 
-tree
-c_omp_address_inspector::expand_map_clause (tree c, tree expr,
+tree *
+c_omp_address_inspector::expand_map_clause (tree *pc, tree expr,
                                            vec<omp_addr_token *> &addr_tokens,
                                            c_omp_region_type ort)
 {
@@ -4192,18 +4195,18 @@ c_omp_address_inspector::expand_map_clause (tree c, 
tree expr,
          && addr_tokens[i]->u.structure_base_kind == BASE_DECL
          && addr_tokens[i + 1]->type == ACCESS_METHOD)
        {
-         c = expand_array_base (c, addr_tokens, expr, &i, ort);
-         if (c == error_mark_node)
-           return error_mark_node;
+         pc = expand_array_base (pc, addr_tokens, expr, &i, ort);
+         if (pc == NULL)
+           return NULL;
        }
       else if (remaining >= 2
               && addr_tokens[i]->type == ARRAY_BASE
               && addr_tokens[i]->u.structure_base_kind == BASE_ARBITRARY_EXPR
               && addr_tokens[i + 1]->type == ACCESS_METHOD)
        {
-         c = expand_array_base (c, addr_tokens, expr, &i, ort);
-         if (c == error_mark_node)
-           return error_mark_node;
+         pc = expand_array_base (pc, addr_tokens, expr, &i, ort);
+         if (pc == NULL)
+           return NULL;
        }
       else if (remaining >= 2
               && addr_tokens[i]->type == STRUCTURE_BASE
@@ -4230,18 +4233,18 @@ c_omp_address_inspector::expand_map_clause (tree c, 
tree expr,
                i++;
              break;
            default:
-             return error_mark_node;
+             return NULL;
            }
        }
       else if (remaining >= 2
               && addr_tokens[i]->type == COMPONENT_SELECTOR
               && addr_tokens[i + 1]->type == ACCESS_METHOD)
        {
-         c = expand_component_selector (c, addr_tokens, expr, &i, ort);
+         pc = expand_component_selector (pc, addr_tokens, expr, &i, ort);
          /* We used 'expr', so these must have been the last tokens.  */
          gcc_assert (i == length);
-         if (c == error_mark_node)
-           return error_mark_node;
+         if (pc == NULL)
+           return NULL;
        }
       else if (remaining >= 3
               && addr_tokens[i]->type == COMPONENT_SELECTOR
@@ -4259,9 +4262,9 @@ c_omp_address_inspector::expand_map_clause (tree c, tree 
expr,
     }
 
   if (i == length)
-    return c;
+    return pc;
 
-  return error_mark_node;
+  return NULL;
 }
 
 /* Given a mapper function MAPPER_FN, recursively scan through the map clauses
diff --git a/gcc/c/ChangeLog.omp b/gcc/c/ChangeLog.omp
index 12de2d6f037..d9e6cdb6ebb 100644
--- a/gcc/c/ChangeLog.omp
+++ b/gcc/c/ChangeLog.omp
@@ -1,3 +1,10 @@
+2023-09-05  Julian Brown  <jul...@codesourcery.com>
+
+       * c-typeck.cc (handle_omp_array_sections): Pass pointer to clause to
+       process instead of clause.
+       (c_finish_omp_clauses): Update calls to handle_omp_array_sections.
+       Handle cases where initial clause might be replaced.
+
 2023-07-06  Julian Brown  <jul...@codesourcery.com>
 
        * c-parser.cc (c_parser_omp_target_data): Instantiate mappers for
diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index 936e0fa7960..449e953b32f 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -14234,8 +14234,9 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> 
&types,
 /* Handle array sections for clause C.  */
 
 static bool
-handle_omp_array_sections (tree &c, enum c_omp_region_type ort)
+handle_omp_array_sections (tree *pc, tree **pnext, enum c_omp_region_type ort)
 {
+  tree c = *pc;
   bool maybe_zero_len = false;
   unsigned int first_non_one = 0;
   bool non_contiguous = false;
@@ -14481,23 +14482,27 @@ handle_omp_array_sections (tree &c, enum 
c_omp_region_type ort)
 
       c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
 
-      tree nc = ai.expand_map_clause (c, first, addr_tokens, ort);
-      if (nc != error_mark_node)
+      tree *npc = ai.expand_map_clause (pc, first, addr_tokens, ort);
+      if (npc != NULL)
        {
          using namespace omp_addr_tokenizer;
 
+         c = *pc;
+
          if (ai.maybe_zero_length_array_section (c))
            OMP_CLAUSE_MAP_MAYBE_ZERO_LENGTH_ARRAY_SECTION (c) = 1;
 
          /* !!! If we're accessing a base decl via chained access
             methods (e.g. multiple indirections), duplicate clause
             detection won't work properly.  Skip it in that case.  */
-         if ((addr_tokens[0]->type == STRUCTURE_BASE
-              || addr_tokens[0]->type == ARRAY_BASE)
+         if (pnext
+             && (addr_tokens[0]->type == STRUCTURE_BASE
+                 || addr_tokens[0]->type == ARRAY_BASE)
              && addr_tokens[0]->u.structure_base_kind == BASE_DECL
              && addr_tokens[1]->type == ACCESS_METHOD
              && omp_access_chain_p (addr_tokens, 1))
-           c = nc;
+           /* NPC points to the last node in the new sequence.  */
+           *pnext = npc;
 
          return false;
        }
@@ -14845,12 +14850,13 @@ c_finish_omp_clauses (tree clauses, enum 
c_omp_region_type ort)
          t = OMP_CLAUSE_DECL (c);
          if (TREE_CODE (t) == OMP_ARRAY_SECTION)
            {
-             if (handle_omp_array_sections (c, ort))
+             if (handle_omp_array_sections (pc, NULL, ort))
                {
                  remove = true;
                  break;
                }
 
+             c = *pc;
              t = OMP_CLAUSE_DECL (c);
              if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
                  && OMP_CLAUSE_REDUCTION_INSCAN (c))
@@ -15574,10 +15580,12 @@ c_finish_omp_clauses (tree clauses, enum 
c_omp_region_type ort)
            last_iterators = NULL_TREE;
          if (TREE_CODE (t) == OMP_ARRAY_SECTION)
            {
-             if (handle_omp_array_sections (c, ort))
+             if (handle_omp_array_sections (pc, NULL, ort))
                remove = true;
-             else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
-                      && OMP_CLAUSE_DEPEND_KIND (c) == 
OMP_CLAUSE_DEPEND_DEPOBJ)
+             else if ((c = *pc)
+                      && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
+                      && (OMP_CLAUSE_DEPEND_KIND (c)
+                          == OMP_CLAUSE_DEPEND_DEPOBJ))
                {
                  error_at (OMP_CLAUSE_LOCATION (c),
                            "%<depend%> clause with %<depobj%> dependence "
@@ -15693,10 +15701,12 @@ c_finish_omp_clauses (tree clauses, enum 
c_omp_region_type ort)
                grp_start_p = pc;
                grp_sentinel = OMP_CLAUSE_CHAIN (c);
 
-               if (handle_omp_array_sections (c, ort))
+               tree *pnext = NULL;
+               if (handle_omp_array_sections (pc, &pnext, ort))
                  remove = true;
                else
                  {
+                   c = *pc;
                    t = OMP_CLAUSE_DECL (c);
                    if (!omp_mappable_type (TREE_TYPE (t)))
                      {
@@ -15792,6 +15802,8 @@ c_finish_omp_clauses (tree clauses, enum 
c_omp_region_type ort)
                     clauses, reset the OMP_CLAUSE_SIZE (representing a bias)
                     to zero here.  */
                  OMP_CLAUSE_SIZE (c) = size_zero_node;
+               if (pnext)
+                 c = *pnext;
                break;
              }
            else if (!omp_parse_expr (addr_tokens, t))
@@ -15990,10 +16002,10 @@ c_finish_omp_clauses (tree clauses, enum 
c_omp_region_type ort)
              {
                grp_start_p = pc;
                grp_sentinel = OMP_CLAUSE_CHAIN (c);
-               tree nc = ai.expand_map_clause (c, OMP_CLAUSE_DECL (c),
-                                               addr_tokens, ort);
-               if (nc != error_mark_node)
-                 c = nc;
+               tree *npc = ai.expand_map_clause (pc, OMP_CLAUSE_DECL (c),
+                                                 addr_tokens, ort);
+               if (npc != NULL)
+                 c = *npc;
              }
          }
          break;
@@ -16093,10 +16105,11 @@ c_finish_omp_clauses (tree clauses, enum 
c_omp_region_type ort)
          t = OMP_CLAUSE_DECL (c);
          if (TREE_CODE (t) == OMP_ARRAY_SECTION)
            {
-             if (handle_omp_array_sections (c, ort))
+             if (handle_omp_array_sections (pc, NULL, ort))
                remove = true;
              else
                {
+                 c = *pc;
                  t = OMP_CLAUSE_DECL (c);
                  while (TREE_CODE (t) == ARRAY_REF)
                    t = TREE_OPERAND (t, 0);
diff --git a/gcc/cp/ChangeLog.omp b/gcc/cp/ChangeLog.omp
index 14acf2bb56a..dd119847314 100644
--- a/gcc/cp/ChangeLog.omp
+++ b/gcc/cp/ChangeLog.omp
@@ -1,3 +1,11 @@
+2023-09-05  Julian Brown  <jul...@codesourcery.com>
+
+       * semantics.cc (handle_omp_array_sections): Pass pointer to clause
+       instead of clause.  Add PNEXT return parameter for next clause in list
+       to process.
+       (finish_omp_clauses): Update calls to handle_omp_array_sections.
+       Handle cases where initial clause might be replaced.
+
 2023-08-10  Julian Brown  <jul...@codesourcery.com>
 
        * pt.cc (tsubst_omp_clauses): Use C_ORT_OMP_DECLARE_MAPPER.
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index 65df7aa4365..a1c8b1bdcd0 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -5899,8 +5899,9 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> 
&types,
 /* Handle array sections for clause C.  */
 
 static bool
-handle_omp_array_sections (tree &c, enum c_omp_region_type ort)
+handle_omp_array_sections (tree *pc, tree **pnext, enum c_omp_region_type ort)
 {
+  tree c = *pc;
   bool maybe_zero_len = false;
   unsigned int first_non_one = 0;
   bool non_contiguous = false;
@@ -6174,23 +6175,27 @@ handle_omp_array_sections (tree &c, enum 
c_omp_region_type ort)
 
          cp_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
 
-         tree nc = ai.expand_map_clause (c, first, addr_tokens, ort);
-         if (nc != error_mark_node)
+         tree* npc = ai.expand_map_clause (pc, first, addr_tokens, ort);
+         if (npc != NULL)
            {
              using namespace omp_addr_tokenizer;
 
+             c = *pc;
+
              if (ai.maybe_zero_length_array_section (c))
                OMP_CLAUSE_MAP_MAYBE_ZERO_LENGTH_ARRAY_SECTION (c) = 1;
 
              /* !!! If we're accessing a base decl via chained access
                 methods (e.g. multiple indirections), duplicate clause
                 detection won't work properly.  Skip it in that case.  */
-             if ((addr_tokens[0]->type == STRUCTURE_BASE
+             if (pnext
+                 && (addr_tokens[0]->type == STRUCTURE_BASE
                   || addr_tokens[0]->type == ARRAY_BASE)
                  && addr_tokens[0]->u.structure_base_kind == BASE_DECL
                  && addr_tokens[1]->type == ACCESS_METHOD
                  && omp_access_chain_p (addr_tokens, 1))
-               c = nc;
+               /* NPC points to the last node in the new sequence.  */
+               *pnext = npc;
 
              return false;
            }
@@ -7322,7 +7327,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type 
ort)
          t = OMP_CLAUSE_DECL (c);
          if (TREE_CODE (t) == OMP_ARRAY_SECTION)
            {
-             if (handle_omp_array_sections (c, ort))
+             if (handle_omp_array_sections (pc, NULL, ort))
                {
                  remove = true;
                  break;
@@ -8458,7 +8463,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type 
ort)
 
          if (TREE_CODE (t) == OMP_ARRAY_SECTION)
            {
-             if (handle_omp_array_sections (c, ort))
+             if (handle_omp_array_sections (pc, NULL, ort))
                remove = true;
              else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
                       && (OMP_CLAUSE_DEPEND_KIND (c)
@@ -8627,10 +8632,13 @@ finish_omp_clauses (tree clauses, enum 
c_omp_region_type ort)
                grp_start_p = pc;
                grp_sentinel = OMP_CLAUSE_CHAIN (c);
 
-               if (handle_omp_array_sections (c, ort))
+               tree *pnext = NULL;
+               if (handle_omp_array_sections (pc, &pnext, ort))
                  remove = true;
                else
                  {
+                   /* We might have replaced the clause, so refresh C.  */
+                   c = *pc;
                    t = OMP_CLAUSE_DECL (c);
                    if (TREE_CODE (t) != OMP_ARRAY_SECTION
                        && !type_dependent_expression_p (t)
@@ -8729,6 +8737,8 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type 
ort)
                     clauses, reset the OMP_CLAUSE_SIZE (representing a bias)
                     to zero here.  */
                  OMP_CLAUSE_SIZE (c) = size_zero_node;
+               if (pnext)
+                 c = *pnext;
                break;
              }
            else if (type_dependent_expression_p (t))
@@ -8976,10 +8986,10 @@ finish_omp_clauses (tree clauses, enum 
c_omp_region_type ort)
              {
                grp_start_p = pc;
                grp_sentinel = OMP_CLAUSE_CHAIN (c);
-               tree nc = ai.expand_map_clause (c, OMP_CLAUSE_DECL (c),
-                                               addr_tokens, ort);
-               if (nc != error_mark_node)
-                 c = nc;
+               tree *npc = ai.expand_map_clause (pc, OMP_CLAUSE_DECL (c),
+                                                 addr_tokens, ort);
+               if (npc != NULL)
+                 c = *npc;
              }
          }
          break;
@@ -9216,10 +9226,11 @@ finish_omp_clauses (tree clauses, enum 
c_omp_region_type ort)
          t = OMP_CLAUSE_DECL (c);
          if (TREE_CODE (t) == OMP_ARRAY_SECTION)
            {
-             if (handle_omp_array_sections (c, ort))
+             if (handle_omp_array_sections (pc, NULL, ort))
                remove = true;
              else
                {
+                 c = *pc;
                  t = OMP_CLAUSE_DECL (c);
                  while (TREE_CODE (t) == OMP_ARRAY_SECTION)
                    t = TREE_OPERAND (t, 0);

Reply via email to