https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102956

            Bug ID: 102956
           Summary: [PDT] KIND and LEN type parameters are mutually
                    exclusive
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anlauf at gcc dot gnu.org
  Target Milestone: ---

F2018: 7.5.3.1  Type parameter definition statement

R732  type-param-def-stmt is
      integer-type-spec, type-param-attr-spec :: type-param-decl-list

R734  type-param-attr-spec  is KIND or LEN

(3) The type-param-attr-spec explicitly specifies whether a type parameter is a
kind parameter or a length parameter.

Thus the KIND and LEN attributes are mutually exclusive.

The follwowing should be rejected:

  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

which is achieved by the trivial patch:

diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
index 2c4acd5abe1..c77f3f84962 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)
     {

Reply via email to