Skip to content

Commit 3b362ee

Browse files
Revert "[flang] Adjust semantics of the char length of an array constructor" (#98612)
Reverts #97337 This has caused llvm test suite failures on our bots, for example: https://lab.llvm.org/buildbot/#/builders/17/builds/709 ``` FAIL: test-suite::gfortran-regression-execute-regression__char_length_21_f90.test FAIL: test-suite::gfortran-regression-execute-regression__char_length_20_f90.test ```
1 parent 5b0dba1 commit 3b362ee

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

flang/lib/Semantics/expression.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,8 +1584,7 @@ class ArrayConstructorContext {
15841584
std::optional<Expr<SubscriptInteger>> LengthIfGood() const {
15851585
if (type_) {
15861586
auto len{type_->LEN()};
1587-
if (explicitType_ ||
1588-
(len && IsConstantExpr(*len) && !ContainsAnyImpliedDoIndex(*len))) {
1587+
if (len && IsConstantExpr(*len) && !ContainsAnyImpliedDoIndex(*len)) {
15891588
return len;
15901589
}
15911590
}

flang/test/Lower/HLFIR/array-ctor-character.f90

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,10 @@ subroutine test_set_length_sanitize(i, c1)
9393
call takes_char([character(len=i):: c1])
9494
end subroutine
9595
! CHECK-LABEL: func.func @_QPtest_set_length_sanitize(
96-
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare {{.*}}Ec1
97-
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %arg0
98-
! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<i64>
99-
! CHECK: %[[VAL_25:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<i64>
96+
! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare {{.*}}Ec1
97+
! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare {{.*}}Ei
98+
! CHECK: %[[VAL_25:.*]] = fir.load %[[VAL_9]]#0 : !fir.ref<i64>
10099
! CHECK: %[[VAL_26:.*]] = arith.constant 0 : i64
101100
! CHECK: %[[VAL_27:.*]] = arith.cmpi sgt, %[[VAL_25]], %[[VAL_26]] : i64
102101
! CHECK: %[[VAL_28:.*]] = arith.select %[[VAL_27]], %[[VAL_25]], %[[VAL_26]] : i64
103-
! CHECK: %[[VAL_29:.*]] = hlfir.set_length %[[VAL_2]]#0 len %[[VAL_28]] : (!fir.boxchar<1>, i64) -> !hlfir.expr<!fir.char<1,?>>
102+
! CHECK: %[[VAL_29:.*]] = hlfir.set_length %[[VAL_6]]#0 len %[[VAL_28]] : (!fir.boxchar<1>, i64) -> !hlfir.expr<!fir.char<1,?>>

flang/test/Semantics/array-constr-len.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ subroutine subr(s,n)
1010
print *, [(s(1:j),j=1,0)]
1111
print *, [(s(1:1),j=1,0)] ! ok
1212
print *, [character(2)::(s(1:n),j=1,0)] ! ok
13+
!ERROR: Array constructor implied DO loop has no iterations and indeterminate character length
1314
print *, [character(n)::(s(1:n),j=1,0)]
1415
end

0 commit comments

Comments
 (0)