Dear all,

the attached patch fixes a 15/16 regression for parsing DO CONCURRENT
when there was another statement following on the same line after a
semicolon, because gfc_match_eos was called twice instead of just once.

The patch was OK'ed by Jerry in the PR, regtested and pushed to mainline
so far as r16-480-g6ce73ad4370c14.

A backport to 15 will follow soon.

Thanks,
Harald

From 4914d9b0ccce843452ab3c921817513441e187ff Mon Sep 17 00:00:00 2001
From: Harald Anlauf <anl...@gmx.de>
Date: Thu, 8 May 2025 22:21:03 +0200
Subject: [PATCH] Fortran: parsing issue with DO CONCURRENT;ENDDO on same line
 [PR120179]

	PR fortran/120179

gcc/fortran/ChangeLog:

	* match.cc (gfc_match_do): Do not attempt to match end-of-statement
	twice.

gcc/testsuite/ChangeLog:

	* gfortran.dg/do_concurrent_basic.f90: Extend testcase.
---
 gcc/fortran/match.cc                              | 3 ++-
 gcc/testsuite/gfortran.dg/do_concurrent_basic.f90 | 7 +++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc
index 474ba81b2aa..a99a757bede 100644
--- a/gcc/fortran/match.cc
+++ b/gcc/fortran/match.cc
@@ -2892,7 +2892,7 @@ gfc_match_do (void)
 	  locus where = gfc_current_locus;
 
 	  if (gfc_match_eos () == MATCH_YES)
-	    break;
+	    goto concurr_ok;
 
 	  else if (gfc_match ("local ( ") == MATCH_YES)
 	    {
@@ -3141,6 +3141,7 @@ gfc_match_do (void)
       if (gfc_match_eos () != MATCH_YES)
 	goto concurr_cleanup;
 
+concurr_ok:
       if (label != NULL
 	   && !gfc_reference_st_label (label, ST_LABEL_DO_TARGET))
 	goto concurr_cleanup;
diff --git a/gcc/testsuite/gfortran.dg/do_concurrent_basic.f90 b/gcc/testsuite/gfortran.dg/do_concurrent_basic.f90
index fe8723d48b4..bdb6e0e6fe2 100644
--- a/gcc/testsuite/gfortran.dg/do_concurrent_basic.f90
+++ b/gcc/testsuite/gfortran.dg/do_concurrent_basic.f90
@@ -1,4 +1,4 @@
-! { dg-do run }
+! { dg-do compile }
 program basic_do_concurrent
   implicit none
   integer :: i, arr(10)
@@ -7,5 +7,8 @@ program basic_do_concurrent
     arr(i) = i
   end do
 
+  do concurrent (i=1:10);enddo
+  do,concurrent (i=1:10);arr(i)=i;enddo
+
   print *, arr
-end program basic_do_concurrent
\ No newline at end of file
+end program basic_do_concurrent
-- 
2.43.0

Reply via email to