Skip to content

Commit fce2948

Browse files
authored
[flang] Fix bogus error on defined I/O procedure. (#125898)
The check that "v_list" be deferred shape is just wrong; there are no deferred shape non-pointer non-allocatable dummy arguments in Fortran. Correct to check for an assumed shape dummy argument. And de-split the error messages that were split across multiple source lines, making them much harder to find with grep. Fixes #125878.
1 parent 3e3855b commit fce2948

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

Diff for: flang/lib/Semantics/check-declarations.cpp

+11-19
Original file line numberDiff line numberDiff line change
@@ -3430,8 +3430,7 @@ void CheckHelper::CheckDioDummyIsDerived(const Symbol &subp, const Symbol &arg,
34303430
}
34313431
} else {
34323432
messages_.Say(arg.name(),
3433-
"Dummy argument '%s' of a defined input/output procedure must have a"
3434-
" derived type"_err_en_US,
3433+
"Dummy argument '%s' of a defined input/output procedure must have a derived type"_err_en_US,
34353434
arg.name());
34363435
}
34373436
}
@@ -3447,16 +3446,14 @@ void CheckHelper::CheckDioDummyIsDefaultInteger(
34473446
}
34483447
}
34493448
messages_.Say(arg.name(),
3450-
"Dummy argument '%s' of a defined input/output procedure"
3451-
" must be an INTEGER of default KIND"_err_en_US,
3449+
"Dummy argument '%s' of a defined input/output procedure must be an INTEGER of default KIND"_err_en_US,
34523450
arg.name());
34533451
}
34543452

34553453
void CheckHelper::CheckDioDummyIsScalar(const Symbol &subp, const Symbol &arg) {
34563454
if (arg.Rank() > 0 || arg.Corank() > 0) {
34573455
messages_.Say(arg.name(),
3458-
"Dummy argument '%s' of a defined input/output procedure"
3459-
" must be a scalar"_err_en_US,
3456+
"Dummy argument '%s' of a defined input/output procedure must be a scalar"_err_en_US,
34603457
arg.name());
34613458
}
34623459
}
@@ -3533,8 +3530,7 @@ void CheckHelper::CheckDioAssumedLenCharacterArg(const Symbol &subp,
35333530
context_.defaultKinds().GetDefaultKind(
35343531
TypeCategory::Character))) {
35353532
messages_.Say(arg->name(),
3536-
"Dummy argument '%s' of a defined input/output procedure"
3537-
" must be assumed-length CHARACTER of default kind"_err_en_US,
3533+
"Dummy argument '%s' of a defined input/output procedure must be assumed-length CHARACTER of default kind"_err_en_US,
35383534
arg->name());
35393535
}
35403536
}
@@ -3547,10 +3543,9 @@ void CheckHelper::CheckDioVlistArg(
35473543
CheckDioDummyIsDefaultInteger(subp, *arg);
35483544
CheckDioDummyAttrs(subp, *arg, Attr::INTENT_IN);
35493545
const auto *objectDetails{arg->detailsIf<ObjectEntityDetails>()};
3550-
if (!objectDetails || !objectDetails->shape().CanBeDeferredShape()) {
3546+
if (!objectDetails || !objectDetails->shape().CanBeAssumedShape()) {
35513547
messages_.Say(arg->name(),
3552-
"Dummy argument '%s' of a defined input/output procedure must be"
3553-
" deferred shape"_err_en_US,
3548+
"Dummy argument '%s' of a defined input/output procedure must be assumed shape"_err_en_US,
35543549
arg->name());
35553550
}
35563551
}
@@ -3565,8 +3560,7 @@ void CheckHelper::CheckDioArgCount(
35653560
: 4)};
35663561
if (argCount != requiredArgCount) {
35673562
SayWithDeclaration(subp,
3568-
"Defined input/output procedure '%s' must have"
3569-
" %d dummy arguments rather than %d"_err_en_US,
3563+
"Defined input/output procedure '%s' must have %d dummy arguments rather than %d"_err_en_US,
35703564
subp.name(), requiredArgCount, argCount);
35713565
context_.SetError(subp);
35723566
}
@@ -3578,15 +3572,13 @@ void CheckHelper::CheckDioDummyAttrs(
35783572
Attrs attrs{arg.attrs()};
35793573
if (!attrs.test(goodIntent)) {
35803574
messages_.Say(arg.name(),
3581-
"Dummy argument '%s' of a defined input/output procedure"
3582-
" must have intent '%s'"_err_en_US,
3575+
"Dummy argument '%s' of a defined input/output procedure must have intent '%s'"_err_en_US,
35833576
arg.name(), AttrToString(goodIntent));
35843577
}
35853578
attrs = attrs - Attr::INTENT_IN - Attr::INTENT_OUT - Attr::INTENT_INOUT;
35863579
if (!attrs.empty()) {
35873580
messages_.Say(arg.name(),
3588-
"Dummy argument '%s' of a defined input/output procedure may not have"
3589-
" any attributes"_err_en_US,
3581+
"Dummy argument '%s' of a defined input/output procedure may not have any attributes"_err_en_US,
35903582
arg.name());
35913583
}
35923584
}
@@ -3599,8 +3591,8 @@ void CheckHelper::CheckDefinedIoProc(const Symbol &symbol,
35993591
const auto *binding{ultimate.detailsIf<ProcBindingDetails>()};
36003592
const Symbol &specific{*(binding ? &binding->symbol() : &ultimate)};
36013593
if (ultimate.attrs().test(Attr::NOPASS)) { // C774
3602-
messages_.Say("Defined input/output procedure '%s' may not have NOPASS "
3603-
"attribute"_err_en_US,
3594+
messages_.Say(
3595+
"Defined input/output procedure '%s' may not have NOPASS attribute"_err_en_US,
36043596
ultimate.name());
36053597
context_.SetError(ultimate);
36063598
}

Diff for: flang/test/Semantics/io11.f90

+1-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ subroutine formattedReadProc(dtv, unit, iotype, vlist, iostat, iomsg)
355355
class(t), intent(inout) :: dtv
356356
integer, intent(in) :: unit
357357
character(len=*), intent(in) :: iotype
358-
!ERROR: Dummy argument 'vlist' of a defined input/output procedure must be deferred shape
358+
!ERROR: Dummy argument 'vlist' of a defined input/output procedure must be assumed shape
359359
integer, intent(in) :: vlist(5)
360360
integer, intent(out) :: iostat
361361
character(len=*), intent(inout) :: iomsg

0 commit comments

Comments
 (0)