[gcc r16-5971] Fortran: [PR123025] Catch Old-style character declarations.
Jerry DeLisle
jvdelisle@gcc.gnu.org
Mon Dec 8 20:48:24 GMT 2025
https://gcc.gnu.org/g:cf270d06000e34cf493ae6625385080e39677af8
commit r16-5971-gcf270d06000e34cf493ae6625385080e39677af8
Author: Harald Anlauf <anlauf@gmx.de>
Date: Mon Dec 8 11:48:29 2025 -0800
Fortran: [PR123025] Catch Old-style character declarations.
Before this patch we missed the two cases here:
character*5 string5 ! Gives obsolescent message
character*(5) string5const ! Silent with constant
character*(2+3) string5expr ! Silent with expression
PR fortran/123025
gcc/fortran/ChangeLog:
* decl.cc (match_char_length): Add a check for the
obsolete '*' style of character declarations in the
alternate branch of checking so we dont miss two
use cases:
gcc/testsuite/ChangeLog:
* gfortran.dg/assumed_charlen_dummy.f90: These tests failed
with the change because of the default -pedantic option
used by the dg.exp mechanisms. Overide this default.
* gfortran.dg/automatic_char_len_1.f90: Ditto.
* gfortran.dg/entry_23.f: Ditto.
* gfortran.dg/finalize_59.f90: Dito.
* gfortran.dg/g77/f90-intrinsic-bit.f: Ditto.
* gfortran.dg/g77/f90-intrinsic-mathematical.f: Ditto.
* gfortran.dg/g77/f90-intrinsic-numeric.f: Ditto.
* gfortran.dg/g77/intrinsic-unix-bessel.f: Ditto.
* gfortran.dg/g77/intrinsic-unix-erf.f: Ditto.
* gfortran.dg/initialization_9.f90: Ditto.
* gfortran.dg/intrinsic_actual_4.f90: Ditto.
* gfortran.dg/namelist_assumed_char.f90: Ditto.
* gfortran.dg/pr15140.f90: Ditto.
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
Diff:
---
gcc/fortran/decl.cc | 4 ++++
gcc/testsuite/gfortran.dg/assumed_charlen_dummy.f90 | 1 +
gcc/testsuite/gfortran.dg/automatic_char_len_1.f90 | 1 +
gcc/testsuite/gfortran.dg/entry_23.f | 1 +
gcc/testsuite/gfortran.dg/finalize_59.f90 | 4 ++--
gcc/testsuite/gfortran.dg/g77/f90-intrinsic-bit.f | 1 +
gcc/testsuite/gfortran.dg/g77/f90-intrinsic-mathematical.f | 1 +
gcc/testsuite/gfortran.dg/g77/f90-intrinsic-numeric.f | 1 +
gcc/testsuite/gfortran.dg/g77/intrinsic-unix-bessel.f | 1 +
gcc/testsuite/gfortran.dg/g77/intrinsic-unix-erf.f | 1 +
gcc/testsuite/gfortran.dg/initialization_9.f90 | 1 +
gcc/testsuite/gfortran.dg/intrinsic_actual_4.f90 | 1 +
gcc/testsuite/gfortran.dg/namelist_assumed_char.f90 | 2 +-
gcc/testsuite/gfortran.dg/pr15140.f90 | 1 +
14 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
index dfedb962bad6..0e55171068b9 100644
--- a/gcc/fortran/decl.cc
+++ b/gcc/fortran/decl.cc
@@ -1217,6 +1217,10 @@ match_char_length (gfc_expr **expr, bool *deferred, bool obsolescent_check)
goto syntax;
}
+ if (obsolescent_check
+ && !gfc_notify_std (GFC_STD_F95_OBS, "Old-style character length at %C"))
+ return MATCH_ERROR;
+
return MATCH_YES;
syntax:
diff --git a/gcc/testsuite/gfortran.dg/assumed_charlen_dummy.f90 b/gcc/testsuite/gfortran.dg/assumed_charlen_dummy.f90
index 04f0b9faaded..2e0e77cf512d 100644
--- a/gcc/testsuite/gfortran.dg/assumed_charlen_dummy.f90
+++ b/gcc/testsuite/gfortran.dg/assumed_charlen_dummy.f90
@@ -1,4 +1,5 @@
! { dg-do compile }
+! { dg-options " " }
! Test the fix for PR fortran/39893.
! Original testcase provided by Deji Akingunola.
! Reduced testcase provided by Dominique d'Humieres.
diff --git a/gcc/testsuite/gfortran.dg/automatic_char_len_1.f90 b/gcc/testsuite/gfortran.dg/automatic_char_len_1.f90
index 3ccfcb70de80..7f102b78dc53 100644
--- a/gcc/testsuite/gfortran.dg/automatic_char_len_1.f90
+++ b/gcc/testsuite/gfortran.dg/automatic_char_len_1.f90
@@ -1,4 +1,5 @@
! { dg-do compile }
+! { dg-options " " }
! PR18082 - Compiler would get stuck in loop, whilst treating
! the assignments.
! Test is one of PR cases.
diff --git a/gcc/testsuite/gfortran.dg/entry_23.f b/gcc/testsuite/gfortran.dg/entry_23.f
index ebc5f6681aa2..d10ea92acf91 100644
--- a/gcc/testsuite/gfortran.dg/entry_23.f
+++ b/gcc/testsuite/gfortran.dg/entry_23.f
@@ -1,4 +1,5 @@
! { dg-do run }
+! { dg-options " " }
! PR 97799 - this used to segfault intermittently.
! Test case by George Hockney.
PROGRAM MAIN
diff --git a/gcc/testsuite/gfortran.dg/finalize_59.f90 b/gcc/testsuite/gfortran.dg/finalize_59.f90
index 8be5f7123a1a..e9e68d429eaf 100644
--- a/gcc/testsuite/gfortran.dg/finalize_59.f90
+++ b/gcc/testsuite/gfortran.dg/finalize_59.f90
@@ -187,7 +187,7 @@ Program Cds_Principal
Type(Uef_Vector) :: Cds_Mod_Les_materiaux
Type (Cds_Materiau_Acier_EC) :: acier_ec
Class (Cds_Materiau), pointer :: pt_materiau
- Character *(8) :: nom_materiau
+ Character(len=8) :: nom_materiau
!-------------------------------------------------------------------------------------------------
CaLL Cds_Mod_Les_materiaux%Add (acier_ec)
nom_materiau = "12345678"
@@ -199,7 +199,7 @@ Function Get_Pt_Materiau_nom (vecteur, nom_materiau)
! Fonction :
!--------------------
! Parametres en entree
- Character *(8), Intent (in) :: nom_materiau
+ Character(len=8), Intent (in) :: nom_materiau
Type (Uef_Vector) , Intent (inout) :: vecteur
! Parametres en sortie
diff --git a/gcc/testsuite/gfortran.dg/g77/f90-intrinsic-bit.f b/gcc/testsuite/gfortran.dg/g77/f90-intrinsic-bit.f
index 0ce45decfb9c..2f03db18b550 100644
--- a/gcc/testsuite/gfortran.dg/g77/f90-intrinsic-bit.f
+++ b/gcc/testsuite/gfortran.dg/g77/f90-intrinsic-bit.f
@@ -1,4 +1,5 @@
c { dg-do run }
+c { dg-options " " }
c f90-intrinsic-bit.f
c
c Test Fortran 90
diff --git a/gcc/testsuite/gfortran.dg/g77/f90-intrinsic-mathematical.f b/gcc/testsuite/gfortran.dg/g77/f90-intrinsic-mathematical.f
index d151fd0a38d8..f07336e939ef 100644
--- a/gcc/testsuite/gfortran.dg/g77/f90-intrinsic-mathematical.f
+++ b/gcc/testsuite/gfortran.dg/g77/f90-intrinsic-mathematical.f
@@ -1,4 +1,5 @@
c { dg-do run }
+c { dg-options " " }
c f90-intrinsic-mathematical.f
c
c Test Fortran 90 intrinsic mathematical functions - Section 13.10.3 and
diff --git a/gcc/testsuite/gfortran.dg/g77/f90-intrinsic-numeric.f b/gcc/testsuite/gfortran.dg/g77/f90-intrinsic-numeric.f
index c8d7c5695240..c01efe6d437f 100644
--- a/gcc/testsuite/gfortran.dg/g77/f90-intrinsic-numeric.f
+++ b/gcc/testsuite/gfortran.dg/g77/f90-intrinsic-numeric.f
@@ -1,4 +1,5 @@
c { dg-do run }
+c { dg-options " " }
c f90-intrinsic-numeric.f
c
c Test Fortran 90 intrinsic numeric functions - Section 13.10.2 and 13.13
diff --git a/gcc/testsuite/gfortran.dg/g77/intrinsic-unix-bessel.f b/gcc/testsuite/gfortran.dg/g77/intrinsic-unix-bessel.f
index b388806399b5..406a8e421659 100644
--- a/gcc/testsuite/gfortran.dg/g77/intrinsic-unix-bessel.f
+++ b/gcc/testsuite/gfortran.dg/g77/intrinsic-unix-bessel.f
@@ -1,4 +1,5 @@
c { dg-do run }
+c { dg-options " " }
c intrinsic-unix-bessel.f
c
c Test Bessel function intrinsics.
diff --git a/gcc/testsuite/gfortran.dg/g77/intrinsic-unix-erf.f b/gcc/testsuite/gfortran.dg/g77/intrinsic-unix-erf.f
index 250519af7b7a..6ed9590b703c 100644
--- a/gcc/testsuite/gfortran.dg/g77/intrinsic-unix-erf.f
+++ b/gcc/testsuite/gfortran.dg/g77/intrinsic-unix-erf.f
@@ -1,4 +1,5 @@
c { dg-do run }
+c { dg-options " " }
c intrinsic-unix-erf.f
c
c Test Bessel function intrinsics.
diff --git a/gcc/testsuite/gfortran.dg/initialization_9.f90 b/gcc/testsuite/gfortran.dg/initialization_9.f90
index d90404748803..fe7ca634a594 100644
--- a/gcc/testsuite/gfortran.dg/initialization_9.f90
+++ b/gcc/testsuite/gfortran.dg/initialization_9.f90
@@ -1,4 +1,5 @@
! { dg-do compile }
+! { dg-options " " }
!
! PR fortran/31639
! Contributed by Martin Michlmayr <tbm AT cyrius DOT com>
diff --git a/gcc/testsuite/gfortran.dg/intrinsic_actual_4.f90 b/gcc/testsuite/gfortran.dg/intrinsic_actual_4.f90
index 4521c968af73..3358b4aeef0a 100644
--- a/gcc/testsuite/gfortran.dg/intrinsic_actual_4.f90
+++ b/gcc/testsuite/gfortran.dg/intrinsic_actual_4.f90
@@ -1,4 +1,5 @@
! { dg-do run }
+! { dg-options " " }
! Tests the fix for PR27900, in which an ICE would be caused because
! the actual argument LEN had no type.
!
diff --git a/gcc/testsuite/gfortran.dg/namelist_assumed_char.f90 b/gcc/testsuite/gfortran.dg/namelist_assumed_char.f90
index b7d063c78b06..25edf648c0ae 100644
--- a/gcc/testsuite/gfortran.dg/namelist_assumed_char.f90
+++ b/gcc/testsuite/gfortran.dg/namelist_assumed_char.f90
@@ -8,7 +8,7 @@
! Add -std=f95, add bar()
!
subroutine foo(c)
- character*(*) c
+ character*(*) c ! { dg-warning "Old-style character length" }
namelist /abc/ c ! { dg-error "nonconstant character length in namelist" }
end subroutine
diff --git a/gcc/testsuite/gfortran.dg/pr15140.f90 b/gcc/testsuite/gfortran.dg/pr15140.f90
index 80c08dda9541..7f9af4fbd76b 100644
--- a/gcc/testsuite/gfortran.dg/pr15140.f90
+++ b/gcc/testsuite/gfortran.dg/pr15140.f90
@@ -1,4 +1,5 @@
! { dg-do run }
+! { dg-options "-std=legacy" }
! PR 15140: we used to fail an assertion, because we don't use the
! argument of the subroutine directly, but instead use a copy of it.
function M(NAMES)
More information about the Gcc-cvs
mailing list