Skip to content

[flang] Defer conversion of PDT default initializers #91026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions flang/lib/Semantics/resolve-names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5550,8 +5550,7 @@ void DeclarationVisitor::Post(const parser::TypeParamDefStmt &x) {
SetType(name, *type);
if (auto &init{
std::get<std::optional<parser::ScalarIntConstantExpr>>(decl.t)}) {
if (auto maybeExpr{EvaluateNonPointerInitializer(
*symbol, *init, init->thing.thing.thing.value().source)}) {
if (auto maybeExpr{AnalyzeExpr(context(), *init)}) {
if (auto *intExpr{std::get_if<SomeIntExpr>(&maybeExpr->u)}) {
symbol->get<TypeParamDetails>().set_init(std::move(*intExpr));
}
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Semantics/modfile12.f90
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ subroutine baz(x)
! real(4)::y(1_8:8_8)
! type::t(c,d)
! integer(4),kind::c=1_4
! integer(4),len::d=3_4
! integer(4),len::d=3_8
! end type
! type(t(c=4_4,d=:)),allocatable::z
! class(t(c=5_4,d=:)),allocatable::z2
Expand Down
6 changes: 3 additions & 3 deletions flang/test/Semantics/modfile17.f90
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ module m
!integer(k8)::j8
!end type
!type::defaulted(n1,n2,n4,n8)
!integer(1),kind::n1=1_1
!integer(2),kind::n2=int(2_4*int(int(n1,kind=1),kind=4),kind=2)
!integer(1),kind::n1=1_4
!integer(2),kind::n2=2_4*int(int(n1,kind=1),kind=4)
!integer(4),kind::n4=2_4*int(int(n2,kind=2),kind=4)
!integer(8),kind::n8=int(12_4-int(n4,kind=4),kind=8)
!integer(8),kind::n8=12_4-int(n4,kind=4)
!type(capture(k1=int(n1,kind=1),k2=int(n2,kind=2),k4=int(n4,kind=4),k8=n8))::cap
!end type
!type,extends(defaulted)::extension(k5)
Expand Down
9 changes: 9 additions & 0 deletions flang/test/Semantics/pdt03.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
type t(kp1,kp2)
integer, kind :: kp1
integer(kp1), kind :: kp2 = kp1
end type
type(t(kp1=8_8)) x
!CHECK: 4_4, 8_4, 8_4, 8_8
print *, kind(x%kp1), x%kp1, kind(x%kp2), x%kp2
end