From: Harald Anlauf Date: Tue, 26 Oct 2021 20:14:19 +0000 (+0200) Subject: Fortran: [PDT] KIND and LEN type parameters are mutually exclusive X-Git-Tag: basepoints/gcc-13~3591 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=662f64a1f9e2de65982e4d895b3afe72cbf581ba;p=thirdparty%2Fgcc.git Fortran: [PDT] KIND and LEN type parameters are mutually exclusive 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. --- diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index 2c4acd5abe17..c77f3f849625 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -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 index 000000000000..f8d404108281 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pdt_32.f03 @@ -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