+2021-06-04 Tobias Burnus <tobias@codesourcery.com>
+
+ Backported from master:
+ 2021-06-04 Tobias Burnus <tobias@codesourcery.com>
+
+ * 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'.
+
2021-06-04 Tobias Burnus <tobias@codesourcery.com>
Backported from master:
&& (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));
&& (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));
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;
{
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 != '&')
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++)
+2021-06-04 Tobias Burnus <tobias@codesourcery.com>
+
+ Backported from master:
+ 2021-06-04 Tobias Burnus <tobias@codesourcery.com>
+
+ * 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.
+
2021-06-04 Tobias Burnus <tobias@codesourcery.com>
Backported from master:
--- /dev/null
+! { dg-additional-options "-fdump-tree-original" }
+
+ ! OMP PARALLEL gets parsed and is properly handled
+ ! But ACC& gives an error
+ ! [Before: an error is printed but OMP parses 'parallel loop ...']
+ subroutine one
+ implicit none
+ integer i
+!$omp parallel
+!$acc& loop independent ! { dg-error "Wrong OpenMP continuation at .1.: expected !.OMP, got !.ACC" }
+ do i = 1, 5
+ end do
+!$omp end parallel
+ end
+
+ ! [Before: Bogus 'Wrong OpenMP continuation' as it was read as continuation line!]
+ subroutine two
+!$omp parallel
+!$acc loop independent ! { dg-error "The !.ACC LOOP directive cannot be specified within a !.OMP PARALLEL region" }
+ do i = 1, 5
+ end do
+!$omp end parallel
+ end
subroutine nana
!$acc parallel &
!$omp do ! { dg-error "Wrong OpenACC continuation" }
+ do i = 1, 5 ! { dg-error "The !.OMP DO directive cannot be specified within a !.ACC PARALLEL region" "" { target *-*-* } .-1 }
+ end do
+ !$acc end parallel
!$omp parallel &
!$acc kernels loop ! { dg-error "Wrong OpenMP continuation" }
+ do i = 1, 5 ! { dg-error "The !.ACC KERNELS LOOP directive cannot be specified within a !.OMP PARALLEL region" "" { target *-*-* } .-1 }
+ end do
+ !$omp end parallel
+
+ !$omp parallel &
+ !$acc loop ! { dg-error "Wrong OpenMP continuation" }
+ do i = 1, 5 ! { dg-error "The !.ACC LOOP directive cannot be specified within a !.OMP PARALLEL region" "" { target *-*-* } .-1 }
+ end do
+ !$omp end parallel
end subroutine nana
end module test