[flang] Tune handling of LEN type parameter discrepancies on ALLOCATE
authorPeter Klausler <pklausler@nvidia.com>
Fri, 17 Mar 2023 21:13:39 +0000 (14:13 -0700)
committerPeter Klausler <pklausler@nvidia.com>
Tue, 28 Mar 2023 00:01:41 +0000 (17:01 -0700)
commitbb6faec1818026a5b7ead29ff98511784ce2cfdd
tree3e4258da295fa2f17fe19478d384b887709c036c
parent36c8a9a9830a321d2b5e3d9dd5b2e7c7da5c56ac
[flang] Tune handling of LEN type parameter discrepancies on ALLOCATE

Presently, semantics doesn't check for discrepancies between known
constant corresponding LEN type parameters between the declared type
of an allocatable/pointer and either the type-spec or the SOURCE=/MOLD=
on an ALLOCATE statement.

This allows discrepancies between character lengths to go unchecked.
Some compilers accept mismatched character lengths on SOURCE=/MOLD=
and the allocate object, and that's useful and unambiguous feature
that already works in f18 via truncation or padding.  A portability
warning should issue, however.

But for mismatched character lengths between an allocate object and
an explicit type-spec, and for any mismatch between derived type
LEN type parameters, an error is appropriate.

Differential Revision: https://reviews.llvm.org/D146583
flang/docs/Extensions.md
flang/lib/Semantics/check-allocate.cpp
flang/test/Semantics/allocate07.f90
flang/test/Semantics/allocate09.f90