https://gcc.gnu.org/g:e2bf0b3910de7e65363435f0a7fa606e2448a677

commit r16-939-ge2bf0b3910de7e65363435f0a7fa606e2448a677
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. A missing comma separator should not be
            encouraged as it is non-standard fortran.
    
            PR fortran/119586
    
    gcc/fortran/ChangeLog:
    
            * io.cc: Set missing comma error checks 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:
---
 gcc/fortran/io.cc                                    | 6 ++++--
 gcc/testsuite/gfortran.dg/comma_format_extension_1.f | 2 +-
 gcc/testsuite/gfortran.dg/comma_format_extension_3.f | 2 +-
 gcc/testsuite/gfortran.dg/continuation_13.f90        | 2 +-
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/gcc/fortran/io.cc b/gcc/fortran/io.cc
index b5c9d3337496..7466d8fe0945 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 a3a5a98f155f..c4b43f01bc3a 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 0b002249b469..9d974d6b90c2 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 9799b59e86ef..475c89639980 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