]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran: Adjust handling of optional comma in FORMAT.
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Wed, 28 May 2025 14:56:12 +0000 (07:56 -0700)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Wed, 28 May 2025 18:13:21 +0000 (11:13 -0700)
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.

gcc/fortran/io.cc
gcc/testsuite/gfortran.dg/comma_format_extension_1.f
gcc/testsuite/gfortran.dg/comma_format_extension_3.f
gcc/testsuite/gfortran.dg/continuation_13.f90

index b5c9d33374968b158339757c175d7e06bd8ea218..7466d8fe0945c2a912b903a2caea1c57e92b1902 100644 (file)
@@ -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.  */
index a3a5a98f155f858367f3153f4f5d87e2c8474dd1..c4b43f01bc3a40a52e4c60c273082ff8932b35bf 100644 (file)
@@ -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
index 0b002249b4697b23a598c869069b90d753d0ed68..9d974d6b90c2dfb7248fb980943a9ae317dd33bd 100644 (file)
@@ -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
index 9799b59e86effdd06b8fd90dc323aebd4979c987..475c89639980837914e4656834057a8e842a6916 100644 (file)
@@ -1,5 +1,5 @@
 ! { dg-do run }
-! { dg-options "-std=gnu" }
+! { dg-options "-std=legacy" }
 ! PR64506
 character(25) :: astring