[flang-commits] [PATCH] D127735: [flang] Support PDT declaration with initial comp value in internal procedure
Jean Perier via Phabricator via flang-commits
flang-commits at lists.llvm.org
Tue Jun 14 05:46:58 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGac64c7b987f1: [flang] Support PDT declaration with initial comp value in internal procedure (authored by jeanPerier).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127735/new/
https://reviews.llvm.org/D127735
Files:
flang/lib/Lower/PFTBuilder.cpp
flang/test/Lower/host-associated.f90
Index: flang/test/Lower/host-associated.f90
===================================================================
--- flang/test/Lower/host-associated.f90
+++ flang/test/Lower/host-associated.f90
@@ -661,3 +661,25 @@
external test_11b
call test_11c(test_11b, 3)
end subroutine test_11a
+
+subroutine test_PDT_with_init_do_not_crash_host_symbol_analysis()
+ integer :: i
+ call sub()
+contains
+ subroutine sub()
+ ! PDT definition symbols maps to un-analyzed expression,
+ ! check this does not crash the visit of the internal procedure
+ ! parse-tree to get the list of captured host variables.
+ type type1 (k)
+ integer, KIND :: k
+ integer :: x = k
+ end type
+ type type2 (k, l)
+ integer, KIND :: k = 4
+ integer, LEN :: l = 2
+ integer :: x = 10
+ real :: y = 20
+ end type
+ print *, i
+ end subroutine
+end subroutine
Index: flang/lib/Lower/PFTBuilder.cpp
===================================================================
--- flang/lib/Lower/PFTBuilder.cpp
+++ flang/lib/Lower/PFTBuilder.cpp
@@ -1768,7 +1768,9 @@
template <typename A>
bool Pre(const A &x) {
if constexpr (Fortran::parser::HasTypedExpr<A>::value)
- if (const auto *expr = Fortran::semantics::GetExpr(x))
+ // Some parse tree Expr may legitimately be un-analyzed after semantics
+ // (for instance PDT component initial value in the PDT definition body).
+ if (const auto *expr = Fortran::semantics::GetExpr(nullptr, x))
visitExpr(*expr);
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127735.436752.patch
Type: text/x-patch
Size: 1542 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220614/d643f152/attachment.bin>
More information about the flang-commits
mailing list