[flang-commits] [PATCH] D109931: [flang] Catch error: base of DATA statement object can't be a pointer
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Wed Sep 22 14:42:01 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG57705df2de9d: [flang] Catch error: base of DATA statement object can't be a pointer (authored by klausler).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109931/new/
https://reviews.llvm.org/D109931
Files:
flang/lib/Semantics/check-data.cpp
flang/test/Semantics/data04.f90
Index: flang/test/Semantics/data04.f90
===================================================================
--- flang/test/Semantics/data04.f90
+++ flang/test/Semantics/data04.f90
@@ -65,6 +65,10 @@
type(large) :: largeNumberArray(i)
type(large) :: largeArray(5)
character :: name(i)
+ type small
+ real :: x
+ end type
+ type(small), pointer :: sp
!C877
!ERROR: Default-initialized 'largenumber' must not be initialized in a DATA statement
DATA(largeNumber % numsArray(j) % headOfTheList, j = 1, 10) / 10 * NULL() /
@@ -92,6 +96,8 @@
!C876
!ERROR: Automatic variable 'name' must not be initialized in a DATA statement
DATA name( : 2) / 'Ancd' /
+ !ERROR: Target of pointer 'sp' must not be initialized in a DATA statement
+ DATA sp%x / 1.0 /
end
end
Index: flang/lib/Semantics/check-data.cpp
===================================================================
--- flang/lib/Semantics/check-data.cpp
+++ flang/lib/Semantics/check-data.cpp
@@ -70,7 +70,9 @@
: IsHostAssociated(symbol, scope) ? "Host-associated object"
: IsUseAssociated(symbol, scope) ? "USE-associated object"
: symbol.has<AssocEntityDetails>() ? "Construct association"
- : nullptr}) {
+ : IsPointer(symbol) && (hasComponent_ || hasSubscript_)
+ ? "Target of pointer"
+ : nullptr}) {
context_.Say(source_,
"%s '%s' must not be initialized in a DATA statement"_err_en_US,
whyNot, symbol.name());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109931.374371.patch
Type: text/x-patch
Size: 1645 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20210922/a1d54b56/attachment.bin>
More information about the flang-commits
mailing list