[flang-commits] [flang] Revert "[flang] Adjust semantics of the char length of an array constructor" (PR #98612)
via flang-commits
flang-commits at lists.llvm.org
Fri Jul 12 03:36:05 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
@llvm/pr-subscribers-flang-semantics
Author: David Spickett (DavidSpickett)
<details>
<summary>Changes</summary>
Reverts llvm/llvm-project#<!-- -->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
```
---
Full diff: https://github.com/llvm/llvm-project/pull/98612.diff
3 Files Affected:
- (modified) flang/lib/Semantics/expression.cpp (+1-2)
- (modified) flang/test/Lower/HLFIR/array-ctor-character.f90 (+4-5)
- (modified) flang/test/Semantics/array-constr-len.f90 (+1)
``````````diff
diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index 844ffd44604ba..90900d9acb6ad 100644
--- a/flang/lib/Semantics/expression.cpp
+++ b/flang/lib/Semantics/expression.cpp
@@ -1584,8 +1584,7 @@ class ArrayConstructorContext {
std::optional<Expr<SubscriptInteger>> LengthIfGood() const {
if (type_) {
auto len{type_->LEN()};
- if (explicitType_ ||
- (len && IsConstantExpr(*len) && !ContainsAnyImpliedDoIndex(*len))) {
+ if (len && IsConstantExpr(*len) && !ContainsAnyImpliedDoIndex(*len)) {
return len;
}
}
diff --git a/flang/test/Lower/HLFIR/array-ctor-character.f90 b/flang/test/Lower/HLFIR/array-ctor-character.f90
index 881085b370ffe..85e6ed27fe077 100644
--- a/flang/test/Lower/HLFIR/array-ctor-character.f90
+++ b/flang/test/Lower/HLFIR/array-ctor-character.f90
@@ -93,11 +93,10 @@ subroutine test_set_length_sanitize(i, c1)
call takes_char([character(len=i):: c1])
end subroutine
! CHECK-LABEL: func.func @_QPtest_set_length_sanitize(
-! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare {{.*}}Ec1
-! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %arg0
-! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<i64>
-! CHECK: %[[VAL_25:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<i64>
+! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare {{.*}}Ec1
+! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare {{.*}}Ei
+! CHECK: %[[VAL_25:.*]] = fir.load %[[VAL_9]]#0 : !fir.ref<i64>
! CHECK: %[[VAL_26:.*]] = arith.constant 0 : i64
! CHECK: %[[VAL_27:.*]] = arith.cmpi sgt, %[[VAL_25]], %[[VAL_26]] : i64
! CHECK: %[[VAL_28:.*]] = arith.select %[[VAL_27]], %[[VAL_25]], %[[VAL_26]] : i64
-! CHECK: %[[VAL_29:.*]] = hlfir.set_length %[[VAL_2]]#0 len %[[VAL_28]] : (!fir.boxchar<1>, i64) -> !hlfir.expr<!fir.char<1,?>>
+! CHECK: %[[VAL_29:.*]] = hlfir.set_length %[[VAL_6]]#0 len %[[VAL_28]] : (!fir.boxchar<1>, i64) -> !hlfir.expr<!fir.char<1,?>>
diff --git a/flang/test/Semantics/array-constr-len.f90 b/flang/test/Semantics/array-constr-len.f90
index 4de9c76c7041c..a785c9e2ece6d 100644
--- a/flang/test/Semantics/array-constr-len.f90
+++ b/flang/test/Semantics/array-constr-len.f90
@@ -10,5 +10,6 @@ subroutine subr(s,n)
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/98612
More information about the flang-commits
mailing list