Skip to content

Commit 6023e24

Browse files
authored
[flang] Error out when assumed rank variable in used as selector in SELECT TYPE statement (#74286)
This patch adds a check to error out when an assumed rank variable is used as dummy argument. Fixes #74285
1 parent 923ff55 commit 6023e24

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

flang/lib/Semantics/check-select-type.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ void SelectTypeChecker::Enter(const parser::SelectTypeConstruct &construct) {
258258
if (IsProcedure(*selector)) {
259259
context_.Say(
260260
selectTypeStmt.source, "Selector may not be a procedure"_err_en_US);
261+
} else if (evaluate::IsAssumedRank(*selector)) {
262+
context_.Say(selectTypeStmt.source,
263+
"Assumed-rank variable may only be used as actual argument"_err_en_US);
261264
} else if (auto exprType{selector->GetType()}) {
262265
const auto &typeCaseList{
263266
std::get<std::list<parser::SelectTypeConstruct::TypeCase>>(

flang/test/Semantics/selecttype01.f90

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,4 +288,11 @@ subroutine CheckNotProcedure
288288
function f() result(res)
289289
class(shape), allocatable :: res
290290
end
291+
292+
subroutine CheckAssumedRankInSelectType(var)
293+
class(*), intent(in) :: var(..)
294+
!ERROR: Assumed-rank variable may only be used as actual argument
295+
select type(var)
296+
end select
297+
end
291298
end

0 commit comments

Comments
 (0)