[flang-commits] [PATCH] D136978: [flang] Complex constructors are scalar only
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Fri Oct 28 13:33:27 PDT 2022
klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a reviewer: sscalpone.
Herald added a project: All.
klausler requested review of this revision.
The common language extension that allows arbitary expressions
to be used as components in a complex constructor (x,y) -- not both
constant, since that would make it a complex literal constant --
still have to be scalar; it's not an elemental operation like the
CMPLX() intrinsic function is.
https://reviews.llvm.org/D136978
Files:
flang/lib/Semantics/expression.cpp
flang/test/Semantics/expr-errors05.f90
Index: flang/test/Semantics/expr-errors05.f90
===================================================================
--- /dev/null
+++ flang/test/Semantics/expr-errors05.f90
@@ -0,0 +1,7 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+! The components of a complex constructor (extension) must be scalar
+!ERROR: Real part of complex constructor must be scalar
+complex, parameter :: z1(*) = ([1.,2.], 3.)
+!ERROR: Imaginary part of complex constructor must be scalar
+complex, parameter :: z2(*) = (4., [5.,6.])
+end
Index: flang/lib/Semantics/expression.cpp
===================================================================
--- flang/lib/Semantics/expression.cpp
+++ flang/lib/Semantics/expression.cpp
@@ -2822,6 +2822,14 @@
const parser::Expr::ComplexConstructor &x) {
auto re{Analyze(std::get<0>(x.t).value())};
auto im{Analyze(std::get<1>(x.t).value())};
+ if (re && re->Rank() > 0) {
+ context().Say(std::get<0>(x.t).value().source,
+ "Real part of complex constructor must be scalar"_err_en_US);
+ }
+ if (im && im->Rank() > 0) {
+ context().Say(std::get<1>(x.t).value().source,
+ "Imaginary part of complex constructor must be scalar"_err_en_US);
+ }
if (re && im) {
ConformabilityCheck(GetContextualMessages(), *re, *im);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136978.471640.patch
Type: text/x-patch
Size: 1282 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20221028/f6e28567/attachment-0001.bin>
More information about the flang-commits
mailing list