Skip to content

Commit 190ae01

Browse files
author
git apple-llvm automerger
committed
Merge commit 'e239f1fc580f' from llvm.org/release/21.x into stable/21.x
2 parents e171c91 + e239f1f commit 190ae01

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

flang/lib/Lower/Mangler.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,18 @@ std::string Fortran::lower::mangle::mangleName(
224224
assert(paramExpr && "derived type kind param not explicit");
225225
std::optional<int64_t> init =
226226
Fortran::evaluate::ToInt64(paramValue->GetExplicit());
227-
assert(init && "derived type kind param is not constant");
228-
kinds.emplace_back(*init);
227+
// TODO: put the assertion check back when parametrized derived types
228+
// are supported:
229+
// assert(init && "derived type kind param is not constant");
230+
//
231+
// The init parameter above will require a FoldingContext for proper
232+
// expression evaluation to an integer constant, otherwise the
233+
// compiler may crash here (see example in issue #127424).
234+
if (!init) {
235+
TODO_NOLOC("parameterized derived types");
236+
} else {
237+
kinds.emplace_back(*init);
238+
}
229239
}
230240
}
231241
return fir::NameUniquer::doType(modules, procs, blockId, symbolName, kinds);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
! RUN: %python %S/test_errors.py %s %flang_fc1
2+
! XFAIL: *
3+
program main
4+
TYPE ty(k1,k2)
5+
INTEGER ,KIND::k1,k2=5
6+
INTEGER::arr(k1:k2)=10
7+
CHARACTER(LEN=k2)::CHARACTER
8+
END TYPE ty
9+
TYPE,EXTENDS(ty)::ty1(k3)
10+
INTEGER,KIND ::k3=4
11+
TYPE(ty(2,k3+1))::cmp_ty = ty(2,k3+1)(55,'HI')
12+
END TYPE ty1
13+
TYPE ty2(l1, l2)
14+
!ERROR: not yet implemented: parameterized derived types
15+
INTEGER,LEN ::l1,l2
16+
TYPE(ty1(2,5)), ALLOCATABLE::ty1_cmp(:)
17+
END TYPE ty2
18+
TYPE(ty2(4,8)) ::ty2_obj
19+
end program main

0 commit comments

Comments
 (0)