[flang-commits] [flang] [flang] Fix another crash from another fuzzer test. (PR #122562)
via flang-commits
flang-commits at lists.llvm.org
Fri Jan 10 16:58:05 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Peter Klausler (klausler)
<details>
<summary>Changes</summary>
Fixes https://github.com/llvm/llvm-project/issues/122045.
---
Full diff: https://github.com/llvm/llvm-project/pull/122562.diff
2 Files Affected:
- (modified) flang/lib/Evaluate/shape.cpp (+1-1)
- (added) flang/test/Semantics/bug122045.f90 (+6)
``````````diff
diff --git a/flang/lib/Evaluate/shape.cpp b/flang/lib/Evaluate/shape.cpp
index c7b2156a3de17a..37efe299e0f1ec 100644
--- a/flang/lib/Evaluate/shape.cpp
+++ b/flang/lib/Evaluate/shape.cpp
@@ -459,7 +459,7 @@ static MaybeExtentExpr GetNonNegativeExtent(
} else {
return ExtentExpr{*uval - *lval + 1};
}
- } else if (lbound && ubound &&
+ } else if (lbound && ubound && lbound->Rank() == 0 && ubound->Rank() == 0 &&
(!invariantOnly ||
(IsScopeInvariantExpr(*lbound) && IsScopeInvariantExpr(*ubound)))) {
// Apply effective IDIM (MAX calculation with 0) so thet the
diff --git a/flang/test/Semantics/bug122045.f90 b/flang/test/Semantics/bug122045.f90
new file mode 100644
index 00000000000000..c68d2bbc142142
--- /dev/null
+++ b/flang/test/Semantics/bug122045.f90
@@ -0,0 +1,6 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+! ERROR: Must be a scalar value, but is a rank-1 array
+! ERROR: Shape of initialized object 'a' must be constant
+complex:: a(n) = SUM([1])
+INTEGER, parameter :: n(2) = [2,2]
+end
``````````
</details>
https://github.com/llvm/llvm-project/pull/122562
More information about the flang-commits
mailing list