[PATCH] Accept commas between clauses in OpenMP declare variant
Paul-Antoine Arras
parras@baylibre.com
Mon Jan 13 17:59:17 GMT 2025
On 13/01/2025 16:51, Tobias Burnus wrote:
> Hi PA,
>
> Paul-Antoine Arras wrote:
>> I am not sure I am getting that part. Is this what you are suggesting?
>
> Yes, something like that, but not quite, as you found out.
>
> I think we need something like the following (untested):
>
>> diff --git gcc/fortran/openmp.cc gcc/fortran/openmp.cc
>> index 9d255558dc9..e3abbeeef98 100644
>> --- gcc/fortran/openmp.cc
>> +++ gcc/fortran/openmp.cc
>> @@ -6532,7 +6532,6 @@ gfc_match_omp_context_selector_specification
>> (gfc_omp_declare_variant *odv)
>> match
>> gfc_match_omp_declare_variant (void)
>> {
>> - bool first_p = true;
>> char buf[GFC_MAX_SYMBOL_LEN + 1];
>>
>> if (gfc_match (" (") != MATCH_YES)
>> @@ -6590,7 +6589,7 @@ gfc_match_omp_declare_variant (void)
>> return MATCH_ERROR;
>> }
>>
>> - bool has_match = false, has_adjust_args = false;
>> + bool has_match = false, has_adjust_args = false, error_p = false;
>> locus adjust_args_loc;
>>
>> for (;;)
>> @@ -6614,13 +6613,9 @@ gfc_match_omp_declare_variant (void)
>> }
>> else
>> {
>> - if (first_p)
>> - {
>> - gfc_error ("expected %<match%> or %<adjust_args%> at %C");
>> - return MATCH_ERROR;
>> - }
>> - else
>> - break;
>> + if (!has_match)
>
>
> if (gfc_match_omp_eos () != MATCH_YES)
>
Yes, exactly what I was missing!
>> + error_p = true;
>> + break;
>> }
>>
>> if (gfc_match (" (") != MATCH_YES)
>> @@ -6666,8 +6661,12 @@ gfc_match_omp_declare_variant (void)
>> for (gfc_omp_namelist *n = *head; n != NULL; n = n->next)
>> n->u.need_device_ptr = true;
>> }
>> + }
>>
>> - first_p = false;
>> + if (error_p)
>
>
> if (error || (!has_match && !has_adjust_args))
>
> as the missing 'match' is handled more explicitly by the next error.
Right.
>> + {
>> + gfc_error ("expected %<match%> or %<adjust_args%> at %C");
>> + return MATCH_ERROR;
>> }
>
> * * *
>
> The rest looks good to me.
>
> Thanks,
>
> Tobias
>
>
Applied, tested and committed.
Thanks,
--
PA
More information about the Fortran
mailing list