diff options
| author | Paul Thomas <pault@gcc.gnu.org> | 2025-10-29 11:06:19 +0000 |
|---|---|---|
| committer | Paul Thomas <pault@gcc.gnu.org> | 2025-10-29 11:06:19 +0000 |
| commit | fe7827c25a4e0965f0600d026448c1d73ca107de (patch) | |
| tree | 64d85412d033a981c20295c0d9283474ec5c631a /gcc | |
| parent | 062e2057265ed6997d7c93c9e35ca1fce5c038be (diff) | |
| download | gcc-fe7827c25a4e0965f0600d026448c1d73ca107de.zip gcc-fe7827c25a4e0965f0600d026448c1d73ca107de.tar.gz gcc-fe7827c25a4e0965f0600d026448c1d73ca107de.tar.bz2 | |
Fortran: PDT - gfortran does not catch F2023:R916 [PR122165]
2025-10-29 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/122165
* primary.cc (gfc_match_varspec): If the previous component ref
was a type specification parameter, a type inquiry ref cannot
follow.
gcc/testsuite
PR fortran/122165
* gfortran.dg/pdt_64.f03: New test.
Diffstat (limited to 'gcc')
| -rw-r--r-- | gcc/fortran/primary.cc | 8 | ||||
| -rw-r--r-- | gcc/testsuite/gfortran.dg/pdt_64.f03 | 17 |
2 files changed, 25 insertions, 0 deletions
diff --git a/gcc/fortran/primary.cc b/gcc/fortran/primary.cc index 2d2c664..0722c76d 100644 --- a/gcc/fortran/primary.cc +++ b/gcc/fortran/primary.cc @@ -2690,6 +2690,14 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag, else component = NULL; + if (previous && inquiry + && (previous->attr.pdt_kind || previous->attr.pdt_len)) + { + gfc_error_now ("R901: A type parameter ref is not a designtor and " + "cannot be followed by the type inquiry ref at %C"); + return MATCH_ERROR; + } + if (intrinsic && !inquiry) { if (previous) diff --git a/gcc/testsuite/gfortran.dg/pdt_64.f03 b/gcc/testsuite/gfortran.dg/pdt_64.f03 new file mode 100644 index 0000000..dfa4e3a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pdt_64.f03 @@ -0,0 +1,17 @@ +! { dg-do compile } +! +! Test the fix for PR122165. +! +! Contributed by Steve Kargl <kargls@comcast.net> +! +program foo + implicit none + type dt(k,l) + integer(8), len :: k = 1 + integer(8), KIND :: l = 1 + character(k) :: arr + end type + type(dt(:)), allocatable :: d1 + if (d1%k%kind /= 8) stop 1 ! { dg-error "cannot be followed by the type inquiry ref" } + if (d1%l%kind /= 8) stop 2 ! { dg-error "cannot be followed by the type inquiry ref" } +end |
