]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran: [PDT] KIND and LEN type parameters are mutually exclusive
authorHarald Anlauf <anlauf@gmx.de>
Tue, 26 Oct 2021 20:14:19 +0000 (22:14 +0200)
committerHarald Anlauf <anlauf@gmx.de>
Tue, 26 Oct 2021 20:14:19 +0000 (22:14 +0200)
gcc/fortran/ChangeLog:

PR fortran/102956
* symbol.c (gfc_check_conflict): Add conflict check for PDT KIND
and LEN type parameters.

gcc/testsuite/ChangeLog:

PR fortran/102956
* gfortran.dg/pdt_32.f03: New test.

gcc/fortran/symbol.c
gcc/testsuite/gfortran.dg/pdt_32.f03 [new file with mode: 0644]

index 2c4acd5abe17211b41efc8b3e63cdbdfa9757ab2..c77f3f849625b52fa9ceb68007098a946c318320 100644 (file)
@@ -720,6 +720,7 @@ gfc_check_conflict (symbol_attribute *attr, const char *name, locus *where)
   conf (pdt_len, pointer)
   conf (pdt_len, dimension)
   conf (pdt_len, codimension)
+  conf (pdt_len, pdt_kind)
 
   if (attr->access == ACCESS_PRIVATE)
     {
diff --git a/gcc/testsuite/gfortran.dg/pdt_32.f03 b/gcc/testsuite/gfortran.dg/pdt_32.f03
new file mode 100644 (file)
index 0000000..f8d4041
--- /dev/null
@@ -0,0 +1,17 @@
+! { dg-do compile }
+! PR fortran/102956
+! PDT KIND and LEN type parameters are mutually exclusive (F2018:R734)
+!
+module m
+  type :: good_pdt (k,l)
+     integer, kind           :: k = 1
+     integer, len            :: l = 1
+     character(kind=k,len=l) :: c
+  end type good_pdt
+
+  type :: bad_pdt (k,l)               ! { dg-error "does not have a component" }
+     integer, kind, len      :: k = 1 ! { dg-error "attribute conflicts with" }
+     integer, len, kind      :: l = 1 ! { dg-error "attribute conflicts with" }
+     character(kind=k,len=l) :: c     ! { dg-error "has not been declared" }
+  end type bad_pdt
+end