On Thu, May 20, 2021 at 10:47:52AM +0200, Marcel Vollweiler wrote:
> --- a/gcc/fortran/openmp.c
> +++ b/gcc/fortran/openmp.c
> @@ -1710,10 +1710,21 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const
> omp_mask mask,
> && gfc_match ("map ( ") == MATCH_YES)
> {
> locus old_loc2 = gfc_current_locus;
> - bool always = false;
> +
> + int always = 0;
> + int close = 0;
The vertical space should be after the 3 variable declarations
rather than in between 1 and 2.
> + for (;;)
> + {
> + if (gfc_match ("always ") == MATCH_YES)
> + always++;
> + else if (gfc_match ("close ") == MATCH_YES)
> + close++;
> + else
> + break;
> + gfc_match (", ");
> + }
> +
> gfc_omp_map_op map_op = OMP_MAP_TOFROM;
> - if (gfc_match ("always , ") == MATCH_YES)
> - always = true;
> if (gfc_match ("alloc : ") == MATCH_YES)
> map_op = OMP_MAP_ALLOC;
> else if (gfc_match ("tofrom : ") == MATCH_YES)
> @@ -1726,11 +1737,24 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const
> omp_mask mask,
> map_op = OMP_MAP_RELEASE;
> else if (gfc_match ("delete : ") == MATCH_YES)
> map_op = OMP_MAP_DELETE;
> - else if (always)
> + else
> {
> gfc_current_locus = old_loc2;
> - always = false;
> + always = 0;
> + close = 0;
> }
> +
> + if (always > 1)
> + {
> + gfc_error ("too many %<always%> modifiers at %C");
> + break;
> + }
> + if (close > 1)
> + {
> + gfc_error ("too many %<close%> modifiers at %C");
> + break;
I think it would be nice to show the locus of the second always or close
modifier. Could the loop above remember that locus when always++ == 1
(or ++always == 2) and similarly for close and use it when printing the
error?
And similarly to the C/C++ patch, better use always_modifier and
close_modifier as the names of the variables, as close is a function and
could be defined as macro.
Jakub