[flang-commits] [flang] [flang] Fix another crash from another fuzzer test. (PR #122562)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Fri Jan 10 16:57:32 PST 2025
https://github.com/klausler created https://github.com/llvm/llvm-project/pull/122562
Fixes https://github.com/llvm/llvm-project/issues/122045.
>From 56f6a3431b9200b28054b95a74daa99720454527 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Fri, 10 Jan 2025 16:56:12 -0800
Subject: [PATCH] [flang] Fix another crash from another fuzzer test.
Fixes https://github.com/llvm/llvm-project/issues/122045.
---
flang/lib/Evaluate/shape.cpp | 2 +-
flang/test/Semantics/bug122045.f90 | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
create mode 100644 flang/test/Semantics/bug122045.f90
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
More information about the flang-commits
mailing list