The attached patch is simple and self explanatory in the git log entry.

Regression tested on X86_64-linux-gnu.

OK for trunk?

Regards,

Jerry
commit 845768cbead03f76265e491bcf5ea6de7020ff39
Author: Jerry DeLisle <jvdeli...@gcc.gnu.org>
Date:   Wed May 28 07:56:12 2025 -0700

    Fortran: Adjust handling of optional comma in FORMAT.
    
            This change adjusts the error messages for optional commas
            in format strings to give a warning at compile time unless
            -std=legacy is used. This is more consistant with the
            runtime library. The comma seprator should really not be
            encouraged as it is non-standard fortran.
    
            PR fortran/119586
    
    gcc/fortran/ChangeLog:
    
            * io.cc: Set error check to STD_STD_LEGACY.
    
    gcc/testsuite/ChangeLog:
    
            * gfortran.dg/comma_format_extension_1.f: Update dg-options to
            "-std=legacy".
            * gfortran.dg/comma_format_extension_3.f: Likewise.
            * gfortran.dg/continuation_13.f90: Likewise.

diff --git a/gcc/fortran/io.cc b/gcc/fortran/io.cc
index b5c9d333749..7466d8fe094 100644
--- a/gcc/fortran/io.cc
+++ b/gcc/fortran/io.cc
@@ -1228,7 +1228,8 @@ between_desc:
     default:
       if (mode != MODE_FORMAT)
 	format_locus.nextc += format_string_pos - 1;
-      if (!gfc_notify_std (GFC_STD_GNU, "Missing comma at %L", &format_locus))
+      if (!gfc_notify_std (GFC_STD_LEGACY,
+	  "Missing comma in FORMAT string at %L", &format_locus))
 	return false;
       /* If we do not actually return a failure, we need to unwind this
          before the next round.  */
@@ -1290,7 +1291,8 @@ extension_optional_comma:
     default:
       if (mode != MODE_FORMAT)
 	format_locus.nextc += format_string_pos;
-      if (!gfc_notify_std (GFC_STD_GNU, "Missing comma at %L", &format_locus))
+      if (!gfc_notify_std (GFC_STD_LEGACY,
+	  "Missing comma in FORMAT string at %L", &format_locus))
 	return false;
       /* If we do not actually return a failure, we need to unwind this
          before the next round.  */
diff --git a/gcc/testsuite/gfortran.dg/comma_format_extension_1.f b/gcc/testsuite/gfortran.dg/comma_format_extension_1.f
index a3a5a98f155..c4b43f01bc3 100644
--- a/gcc/testsuite/gfortran.dg/comma_format_extension_1.f
+++ b/gcc/testsuite/gfortran.dg/comma_format_extension_1.f
@@ -1,5 +1,5 @@
 ! { dg-do compile }
-! { dg-options "" }
+! { dg-options "-std=legacy" }
 ! test that the extension for a missing comma is accepted
 
       subroutine mysub
diff --git a/gcc/testsuite/gfortran.dg/comma_format_extension_3.f b/gcc/testsuite/gfortran.dg/comma_format_extension_3.f
index 0b002249b46..9d974d6b90c 100644
--- a/gcc/testsuite/gfortran.dg/comma_format_extension_3.f
+++ b/gcc/testsuite/gfortran.dg/comma_format_extension_3.f
@@ -3,7 +3,7 @@
 ! did do the correct thing at runtime.
 ! Note the missing , before i1 in the format.
 ! { dg-do run }
-! { dg-options "" }
+! { dg-options "-std=legacy" }
       character*12 c
 
       write (c,100) 0, 1
diff --git a/gcc/testsuite/gfortran.dg/continuation_13.f90 b/gcc/testsuite/gfortran.dg/continuation_13.f90
index 9799b59e86e..475c8963998 100644
--- a/gcc/testsuite/gfortran.dg/continuation_13.f90
+++ b/gcc/testsuite/gfortran.dg/continuation_13.f90
@@ -1,5 +1,5 @@
 ! { dg-do run }
-! { dg-options "-std=gnu" }
+! { dg-options "-std=legacy" }
 ! PR64506
 character(25) :: astring
 

Reply via email to