Cesar Philippidis wrote:
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;I think openmp and openacc should be able to coexist, so that should be left in for now.
Well, -fopenmp and -fopenacc should coexist, which means that both gfc_option.gfc_flag_openmp (or gfc_option.gfc_flag_openmp_simd) and gfc_option.gfc_flag_openacc should coexist. However, openacc_flag and openmp_flag are used for continuation lines – and the same line cannot be simultaneously an OpenMP and an OpenACC statement. Thus, openacc_flag and openmp_flag should be mutually exclusive.
I don't know whether it makes a difference in practice; if it doesn't one could also change it into a single flag. However, I would simply ensure that maximally only one is set at a given time.
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 () == '$') ... 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.
I still think that there is something wrong with the gfc_current_local handling above – even if it is not behind the bug we are currently seeing. In addition, I wonder whether the inner else branch couldn't be merged, i.e. the one which takes care of conditional compilation of the form
!$ This line is a comment, unless -fopenmp or -fopenacc is enabled Those checks appear twice for fixed-form source code and the code is 24 lines long in either case.
The problem was inside skip_fixed_comments. The openacc_flag wasn't being set to zero at the end of that function. [...] Thomas, is this patch ok for gomp-4_0-branch? If so, please check it in.
Looks good to me. Thanks for the patch. Tobias
