Skip to content

Commit fe58527

Browse files
authored
[flang] Relax ETIME(VALUES=) runtime checking (#107647)
Don't require the "VALUES=" argument to the extension intrinsic procedure ETIME to have exactly two elements. Other compilers that support ETIME do not, and it's easy to adapt the behavior to whatever the dynamic size turns out to be.
1 parent d2126ec commit fe58527

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

flang/runtime/time-intrinsic.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -490,16 +490,20 @@ void RTNAME(Etime)(const Descriptor *values, const Descriptor *time,
490490
auto typeCode{values->type().GetCategoryAndKind()};
491491
// ETIME values argument must have decimal range == 2.
492492
RUNTIME_CHECK(terminator,
493-
values->rank() == 1 && values->GetDimension(0).Extent() == 2 &&
494-
typeCode && typeCode->first == Fortran::common::TypeCategory::Real);
493+
values->rank() == 1 && typeCode &&
494+
typeCode->first == Fortran::common::TypeCategory::Real);
495495
// Only accept KIND=4 here.
496496
int kind{typeCode->second};
497497
RUNTIME_CHECK(terminator, kind == 4);
498-
499-
ApplyFloatingPointKind<StoreFloatingPointAt, void>(
500-
kind, terminator, *values, /* atIndex = */ 0, usrTime);
501-
ApplyFloatingPointKind<StoreFloatingPointAt, void>(
502-
kind, terminator, *values, /* atIndex = */ 1, sysTime);
498+
auto extent{values->GetDimension(0).Extent()};
499+
if (extent >= 1) {
500+
ApplyFloatingPointKind<StoreFloatingPointAt, void>(
501+
kind, terminator, *values, /* atIndex = */ 0, usrTime);
502+
}
503+
if (extent >= 2) {
504+
ApplyFloatingPointKind<StoreFloatingPointAt, void>(
505+
kind, terminator, *values, /* atIndex = */ 1, sysTime);
506+
}
503507
}
504508

505509
if (time) {

0 commit comments

Comments
 (0)