[GOMP4, OpenACC] Fixed-form Fortran code failing to parse
Tobias Burnus
burnus@net-b.de
Wed Jul 2 19:15:00 GMT 2014
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.
> 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;
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.
Tobias
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.
More information about the Fortran
mailing list