]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
OpenMP/Fortran: Group handling of 'if' clause without and with modifier
authorThomas Schwinge <thomas@codesourcery.com>
Tue, 24 Oct 2023 08:43:40 +0000 (10:43 +0200)
committerThomas Schwinge <thomas@codesourcery.com>
Wed, 25 Oct 2023 08:49:55 +0000 (10:49 +0200)
The 'if' clause with modifier was introduced in
commit b4c3a85be96585374bf95c981ba2f602667cf5b7 (Subversion r242037)
"Partial OpenMP 4.5 fortran support", but -- in some instances -- didn't place
it next to the existing handling of 'if' clause without modifier.  Unify that;
no change in behavior.

gcc/fortran/
* dump-parse-tree.cc (show_omp_clauses): Group handling of 'if'
clause without and with modifier.
* frontend-passes.cc (gfc_code_walker): Likewise.
* gfortran.h (gfc_omp_clauses): Likewise.
* openmp.cc (gfc_free_omp_clauses): Likewise.

gcc/fortran/dump-parse-tree.cc
gcc/fortran/frontend-passes.cc
gcc/fortran/gfortran.h
gcc/fortran/openmp.cc

index 68122e3e6fdcd279cd37da3ce51fff33eaf49180..cc4846e5d745fc64c73579b23d5ca4ed6bf7c919 100644 (file)
@@ -1593,6 +1593,27 @@ show_omp_clauses (gfc_omp_clauses *omp_clauses)
       show_expr (omp_clauses->if_expr);
       fputc (')', dumpfile);
     }
+  for (i = 0; i < OMP_IF_LAST; i++)
+    if (omp_clauses->if_exprs[i])
+      {
+       static const char *ifs[] = {
+         "CANCEL",
+         "PARALLEL",
+         "SIMD",
+         "TASK",
+         "TASKLOOP",
+         "TARGET",
+         "TARGET DATA",
+         "TARGET UPDATE",
+         "TARGET ENTER DATA",
+         "TARGET EXIT DATA"
+       };
+      fputs (" IF(", dumpfile);
+      fputs (ifs[i], dumpfile);
+      fputs (": ", dumpfile);
+      show_expr (omp_clauses->if_exprs[i]);
+      fputc (')', dumpfile);
+    }
   if (omp_clauses->final_expr)
     {
       fputs (" FINAL(", dumpfile);
@@ -1999,27 +2020,6 @@ show_omp_clauses (gfc_omp_clauses *omp_clauses)
       show_expr (omp_clauses->detach);
       fputc (')', dumpfile);
     }
-  for (i = 0; i < OMP_IF_LAST; i++)
-    if (omp_clauses->if_exprs[i])
-      {
-       static const char *ifs[] = {
-         "CANCEL",
-         "PARALLEL",
-         "SIMD",
-         "TASK",
-         "TASKLOOP",
-         "TARGET",
-         "TARGET DATA",
-         "TARGET UPDATE",
-         "TARGET ENTER DATA",
-         "TARGET EXIT DATA"
-       };
-      fputs (" IF(", dumpfile);
-      fputs (ifs[i], dumpfile);
-      fputs (": ", dumpfile);
-      show_expr (omp_clauses->if_exprs[i]);
-      fputc (')', dumpfile);
-    }
   if (omp_clauses->destroy)
     fputs (" DESTROY", dumpfile);
   if (omp_clauses->depend_source)
index 536884b13f09a62ee643052fb31e6b39c3961599..0378e0dba0628d48aa0e0431654f3ff7b798da9f 100644 (file)
@@ -5652,6 +5652,8 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t codefn, walk_expr_fn_t exprfn,
                        OMP_LIST_MAP, OMP_LIST_TO, OMP_LIST_FROM };
                  size_t idx;
                  WALK_SUBEXPR (co->ext.omp_clauses->if_expr);
+                 for (idx = 0; idx < OMP_IF_LAST; idx++)
+                   WALK_SUBEXPR (co->ext.omp_clauses->if_exprs[idx]);
                  WALK_SUBEXPR (co->ext.omp_clauses->final_expr);
                  WALK_SUBEXPR (co->ext.omp_clauses->num_threads);
                  WALK_SUBEXPR (co->ext.omp_clauses->chunk_size);
@@ -5667,8 +5669,6 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t codefn, walk_expr_fn_t exprfn,
                  WALK_SUBEXPR (co->ext.omp_clauses->num_tasks);
                  WALK_SUBEXPR (co->ext.omp_clauses->priority);
                  WALK_SUBEXPR (co->ext.omp_clauses->detach);
-                 for (idx = 0; idx < OMP_IF_LAST; idx++)
-                   WALK_SUBEXPR (co->ext.omp_clauses->if_exprs[idx]);
                  for (idx = 0; idx < ARRAY_SIZE (list_types); idx++)
                    for (n = co->ext.omp_clauses->lists[list_types[idx]];
                         n; n = n->next)
index 88f33b0957e9a01f3c4791c6c1e3cf211d005c24..9c1a39a19de4086cc795a9d06392e513245e586f 100644 (file)
@@ -1545,6 +1545,7 @@ typedef struct gfc_omp_clauses
 {
   gfc_omp_namelist *lists[OMP_LIST_NUM];
   struct gfc_expr *if_expr;
+  struct gfc_expr *if_exprs[OMP_IF_LAST];
   struct gfc_expr *final_expr;
   struct gfc_expr *num_threads;
   struct gfc_expr *chunk_size;
@@ -1561,7 +1562,6 @@ typedef struct gfc_omp_clauses
   struct gfc_expr *priority;
   struct gfc_expr *detach;
   struct gfc_expr *depobj;
-  struct gfc_expr *if_exprs[OMP_IF_LAST];
   struct gfc_expr *dist_chunk_size;
   struct gfc_expr *message;
   struct gfc_omp_assumptions *assume;
index 1cc65d7fa4990044c46800b0c989510c5216851d..caa5c9e15a30c7cbebbb3ba67e4bcbd4f47c2307 100644 (file)
@@ -161,6 +161,8 @@ gfc_free_omp_clauses (gfc_omp_clauses *c)
     return;
 
   gfc_free_expr (c->if_expr);
+  for (i = 0; i < OMP_IF_LAST; i++)
+    gfc_free_expr (c->if_exprs[i]);
   gfc_free_expr (c->final_expr);
   gfc_free_expr (c->num_threads);
   gfc_free_expr (c->chunk_size);
@@ -176,8 +178,6 @@ gfc_free_omp_clauses (gfc_omp_clauses *c)
   gfc_free_expr (c->num_tasks);
   gfc_free_expr (c->priority);
   gfc_free_expr (c->detach);
-  for (i = 0; i < OMP_IF_LAST; i++)
-    gfc_free_expr (c->if_exprs[i]);
   gfc_free_expr (c->async_expr);
   gfc_free_expr (c->gang_num_expr);
   gfc_free_expr (c->gang_static_expr);