[PATCH] D81096: [flang] Fix IsConstantExpr for division expressions
Jean Perier via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 3 08:12:20 PDT 2020
jeanPerier created this revision.
Herald added a reviewer: DavidTruby.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
jeanPerier added reviewers: klausler, schweitz, PeteSteinfeld.
jeanPerier added a project: Flang.
Herald added a reviewer: jdoerfert.
Fortran::evaluate::IsConstantExpr did not check that the numerator
was a constant expression. This patch fixes the issue.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D81096
Files:
flang/lib/Evaluate/check-expression.cpp
flang/test/Semantics/resolve37.f90
Index: flang/test/Semantics/resolve37.f90
===================================================================
--- flang/test/Semantics/resolve37.f90
+++ flang/test/Semantics/resolve37.f90
@@ -29,6 +29,11 @@
integer, parameter :: p = 0/0
!ERROR: Must be a constant value
integer, parameter :: q = 1+2*(1/0)
+integer not_constant
+!ERROR: Must be a constant value
+integer, parameter :: s1 = not_constant/2
+!ERROR: Must be a constant value
+integer, parameter :: s2 = 3/not_constant
!ERROR: Must be a constant value
integer(kind=2/0) r
integer, parameter :: sok(*)=[1,2]/[1,2]
Index: flang/lib/Evaluate/check-expression.cpp
===================================================================
--- flang/lib/Evaluate/check-expression.cpp
+++ flang/lib/Evaluate/check-expression.cpp
@@ -68,7 +68,7 @@
const Divide<Type<TypeCategory::Integer, KIND>> &division) const {
using T = Type<TypeCategory::Integer, KIND>;
if (const auto divisor{GetScalarConstantValue<T>(division.right())}) {
- return !divisor->IsZero();
+ return !divisor->IsZero() && (*this)(division.left());
} else {
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81096.268197.patch
Type: text/x-patch
Size: 1143 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200603/243ea7d0/attachment.bin>
More information about the llvm-commits
mailing list