Files
clang-p2996/flang/test/Semantics/array-constr-len.f90
Peter Klausler 9c446da556 [flang] More compile-time error checking for null implied DO loops in array constructors
An implied DO loop in an array constructor may not have a type (explicit
or otherwise) with a character length that depends on a value of an
implied DO index or a non-constant expression if the implied DO loop
executes no iterations.  When the iteration count can be known to be
zero at compilation time, catch the case of a non-constant length
expression correctly.

Differential Revision: https://reviews.llvm.org/D156753
2023-08-01 09:05:41 -07:00

16 lines
726 B
Fortran

! RUN: %python %S/test_errors.py %s %flang_fc1
! Confirm enforcement of F'2023 7.8 p5
subroutine subr(s,n)
character*(*) s
!ERROR: Array constructor implied DO loop has no iterations and indeterminate character length
print *, [(s(1:n),j=1,0)]
!ERROR: Array constructor implied DO loop has no iterations and indeterminate character length
print *, [(s(1:n),j=0,1,-1)]
!ERROR: Array constructor implied DO loop has no iterations and indeterminate character length
print *, [(s(1:j),j=1,0)]
print *, [(s(1:1),j=1,0)] ! ok
print *, [character(2)::(s(1:n),j=1,0)] ! ok
!ERROR: Array constructor implied DO loop has no iterations and indeterminate character length
print *, [character(n)::(s(1:n),j=1,0)]
end