On Sat, Jul 20, 2024 at 02:42:26PM -0600, Sandra Loosemore wrote:
> This patch adds support for metadirectives to the Fortran front end.
> +  else if (c->op == EXEC_OMP_METADIRECTIVE)
> +    {
> +      gfc_omp_variant *variant
> +     = c->ext.omp_variants;

Why two lines?  This is short enough to fit on one.

> +      if (begin_p && directive != ST_NONE
> +       && gfc_omp_end_stmt (directive) == ST_NONE)

When the whole condition doesn't fit on one line, each && (or ||) should
be on a separate line.

> +       gfc_error (
> +         "Unexpected %s statement in an OMP METADIRECTIVE block at %C",
> +         gfc_ascii_statement (st));

Please avoid calls with opening ( at end of line if possible, they are too
ugly.
          gfc_error ("Unexpected %s statement in an OMP METADIRECTIVE "
                     "block at %C", gfc_ascii_statement (st));
looks better.

> +     case ST_OMP_END_METADIRECTIVE:
> +       if (gfc_state_stack->state == COMP_OMP_BEGIN_METADIRECTIVE)
> +         {
> +           st = next_statement ();
> +           return st;
> +         }
> +       /* FALLTHRU */

When the stmt to fall through is just return st;, /* FALLTHRU */
seems unnecessary.  Just do
          if (gfc_state_stack->state == COMP_OMP_BEGIN_METADIRECTIVE)
            return next_statement ();
          else
            return st;
> +
>       default:
>         return st;
>       }

> --- a/gcc/fortran/trans-decl.cc
> +++ b/gcc/fortran/trans-decl.cc
> @@ -331,7 +331,10 @@ gfc_get_label_decl (gfc_st_label * lp)
>        gcc_assert (lp != NULL && lp->value <= MAX_LABEL_VALUE);
>  
>        /* Build a mangled name for the label.  */
> -      sprintf (label_name, "__label_%.6d", lp->value);
> +      if (lp->omp_region)
> +     sprintf (label_name, "__label_%d_%.6d", lp->omp_region, lp->value);
> +      else
> +     sprintf (label_name, "__label_%.6d", lp->value);

Makes me wonder what will happen if there are nested metadirectives (or is
omp_region unique in the whole function or TU rather than just in one
metadirective)?

!$omp metadirective ... say conditional teams here
!$omp metadirective ... say conditional parallel here
some code that needs labels
!$omp end metadirective
!$omp end metadirective

        Jakub

Reply via email to