https://gcc.gnu.org/g:6ce73ad4370c143a7d1e6a13b1d353db5884213f

commit r16-480-g6ce73ad4370c143a7d1e6a13b1d353db5884213f
Author: Harald Anlauf <anl...@gmx.de>
Date:   Thu May 8 22:21:03 2025 +0200

    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.

Diff:
---
 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 474ba81b2aa0..a99a757bede6 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 fe8723d48b4c..bdb6e0e6fe21 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

Reply via email to