diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2021-06-04 17:43:59 +0200 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2021-06-04 17:44:23 +0200 |
commit | 4facf2bf5b7b32f444da864306b5c11e14c15bcf (patch) | |
tree | 0b74515b5819d17fa2a64f5260b03628a6ac0c1f /gcc/fortran/scanner.c | |
parent | 8d7dae0eb366a88a1baba1857ecc54c09e4a520e (diff) | |
download | gcc-4facf2bf5b7b32f444da864306b5c11e14c15bcf.zip gcc-4facf2bf5b7b32f444da864306b5c11e14c15bcf.tar.gz gcc-4facf2bf5b7b32f444da864306b5c11e14c15bcf.tar.bz2 |
Fortran: Fix OpenMP/OpenACC continue-line parsing
gcc/fortran/ChangeLog:
* scanner.c (skip_fixed_omp_sentinel): Set openacc_flag if
this is not an (OpenMP) continuation line.
(skip_fixed_oacc_sentinel): Likewise for openmp_flag and OpenACC.
(gfc_next_char_literal): gfc_error_now to force error for mixed OMP/ACC
continuation once per location and return '\n'.
gcc/testsuite/ChangeLog:
* gfortran.dg/goacc/omp-fixed.f: Re-add test item changed in previous
commit in addition - add more dg-errors and '... end ...' due to changed
parsing.
* gfortran.dg/goacc/omp.f95: Likewise.
* gfortran.dg/goacc-gomp/mixed-1.f: New test.
Diffstat (limited to 'gcc/fortran/scanner.c')
-rw-r--r-- | gcc/fortran/scanner.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index 74c5461..39db099 100644 --- a/gcc/fortran/scanner.c +++ b/gcc/fortran/scanner.c @@ -942,6 +942,8 @@ skip_fixed_omp_sentinel (locus *start) && (continue_flag || c == ' ' || c == '\t' || c == '0')) { + if (c == ' ' || c == '\t' || c == '0') + openacc_flag = 0; do c = next_char (); while (gfc_is_whitespace (c)); @@ -971,6 +973,8 @@ skip_fixed_oacc_sentinel (locus *start) && (continue_flag || c == ' ' || c == '\t' || c == '0')) { + if (c == ' ' || c == '\t' || c == '0') + openmp_flag = 0; do c = next_char (); while (gfc_is_whitespace (c)); @@ -1205,6 +1209,7 @@ gfc_skip_comments (void) gfc_char_t gfc_next_char_literal (gfc_instring in_string) { + static locus omp_acc_err_loc = {}; locus old_loc; int i, prev_openmp_flag, prev_openacc_flag; gfc_char_t c; @@ -1403,14 +1408,16 @@ restart: { if (gfc_wide_tolower (c) != (unsigned char) "!$acc"[i]) is_openmp = 1; - if (i == 4) - old_loc = gfc_current_locus; } - gfc_error (is_openmp - ? G_("Wrong OpenACC continuation at %C: " - "expected !$ACC, got !$OMP") - : G_("Wrong OpenMP continuation at %C: " - "expected !$OMP, got !$ACC")); + if (omp_acc_err_loc.nextc != gfc_current_locus.nextc + || omp_acc_err_loc.lb != gfc_current_locus.lb) + gfc_error_now (is_openmp + ? G_("Wrong OpenACC continuation at %C: " + "expected !$ACC, got !$OMP") + : G_("Wrong OpenMP continuation at %C: " + "expected !$OMP, got !$ACC")); + omp_acc_err_loc = gfc_current_locus; + goto not_continuation; } if (c != '&') @@ -1511,11 +1518,15 @@ restart: if (gfc_wide_tolower (c) != (unsigned char) "*$acc"[i]) is_openmp = 1; } - gfc_error (is_openmp - ? G_("Wrong OpenACC continuation at %C: " - "expected !$ACC, got !$OMP") - : G_("Wrong OpenMP continuation at %C: " - "expected !$OMP, got !$ACC")); + if (omp_acc_err_loc.nextc != gfc_current_locus.nextc + || omp_acc_err_loc.lb != gfc_current_locus.lb) + gfc_error_now (is_openmp + ? G_("Wrong OpenACC continuation at %C: " + "expected !$ACC, got !$OMP") + : G_("Wrong OpenMP continuation at %C: " + "expected !$OMP, got !$ACC")); + omp_acc_err_loc = gfc_current_locus; + goto not_continuation; } else if (!openmp_flag && !openacc_flag) for (i = 0; i < 5; i++) |