[GOMP4, OpenACC] Fixed-form Fortran code failing to parse

Cesar Philippidis cesar@codesourcery.com
Thu Jul 3 00:28:00 GMT 2014


On 07/02/2014 12:02 PM, Tobias Burnus wrote:
> Thomas Schwinge wrote:
>> In -fopenmp mode as well as in combined -fopenacc -fopenmp mode as
>> well as in "regular" (no -fopen*) mode, it parses fine.
> 
> [Note I am testing with an outdated branch (20140404), but it still
> might be representative.]
> 
> I am not sure it parses fine in the combined more. If I use
> 
> *$ACC xPARALLEL
> 
> i.e. add a typo, it fails to diagnose it in the combined mode. It does
> diagnose it for -fopenacc:
> 
> *$ACC xPARALLEL COPYIN(ARGC)                                          
>       1
> Error: Unclassifiable OpenACC directive at (1)
> 
> And it does diagnose the problem for $OMP in only OpenMP and in combined
> mode.

Thanks for catching that.

>> I couldn't find anything obvious in gcc/fortran/parse.c; is someone
>> able to have a more in-depth look than I have?
> 
> First, some minor point, I think one should crosswise reset the
> {openmp,openacc}_flag, i.e.
> 
> --- a/gcc/fortran/scanner.c
> +++ b/gcc/fortran/scanner.c
> @@ -735,2 +735,3 @@ skip_oacc_attribute (locus start, locus old_loc,
> bool continue_flag)
>               openacc_flag = 1;
> +              openmp_flag = 0;
>               openacc_locus = old_loc;
> @@ -775,2 +776,3 @@ skip_omp_attribute (locus start, locus old_loc, bool
> continue_flag)
>               openmp_flag = 1;
> +             openacc_flag = 0;
>               openmp_locus = old_loc;
> @@ -826,3 +828,3 @@ skip_free_comments (void)
>           /* Keep the !GCC$ line.  */
> -                 if (at_bol && skip_gcc_attribute (start))
> +         if (at_bol && skip_gcc_attribute (start))
>             return false;

I think openmp and openacc should be able to coexist, so that should be
left in for now.

> Secondly, the following looks wrong (also scanner.c). I have the feeling
> that this could be behind the issue above. But in any case, it looks
> wrong to me.
> 
> 
> skip_fixed_comments (void)
> ...
>       start = gfc_current_locus;
>       c = next_char ();
>       if (c == '!' || c == 'c' || c == 'C' || c == '*')
>           if (gfc_option.gfc_flag_openmp)
>             {
>               if (next_char () == '$')
>                 {
>                   c = next_char ();
>                   if (c == 'o' || c == 'O')
>                     {
> ...
>               gfc_current_locus = start;
> ...
>             }
> 
>           if (gfc_option.gfc_flag_openacc)
>             {
>               if (next_char () == '$')
>                 {
> 
> Namely: If "omp" or the "!$" continuation lines hasn't been matched, one
> returns to "start". However, start is "!" or "*" in this case and not
> "$". In addition, also in this case, one might want to set the other
> flag to 0.
> 
> 
> My feeling is that the bug is also related to something in scanner.c.

The problem was inside skip_fixed_comments. The openacc_flag wasn't
being set to zero at the end of that function. That's bad, because acc
directive can't continue across multiple comments. E.g.

!$acc
! parallel

is invalid. This patch fixes that.

Thomas, is this patch ok for gomp-4_0-branch? If so, please check it in.

Thanks,
Cesar

> PS: I might try later to find out what goes wrong, but that requires in
> any case a binary which is not older than the source code.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: fixed.diff
Type: text/x-patch
Size: 1624 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20140703/c3c9a757/attachment.bin>


More information about the Fortran mailing list