PR fortran/102956 - PDT KIND and LEN type parameters are mutually exclusive
Commit Message
Dear Fortranners,
we were missing a conflict check for PDT KIND and LEN type parameters:
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 attached trivial patch remedies that.
Regtested on x86_64-pc-linux-gnu. OK for mainline?
Thanks,
Harald
Comments
On 26.10.21 21:40, Harald Anlauf via Fortran wrote:
> we were missing a conflict check for PDT KIND and LEN type parameters:
>
>
> 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 attached trivial patch remedies that.
>
> Regtested on x86_64-pc-linux-gnu. OK for mainline?
LGTM, thanks.
Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
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.
@@ -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)
{
new file mode 100644
@@ -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