diff --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp --- a/flang/lib/Semantics/check-call.cpp +++ b/flang/lib/Semantics/check-call.cpp @@ -675,6 +675,13 @@ common::visit( common::visitors{ [&](const characteristics::DummyDataObject &object) { + if (arg.isAlternateReturn()) { + auto restorer{messages.SetLocation( + arg.sourceLocation().value_or(messages.at()))}; + messages.Say("Label '%d' can't be associated with %s"_err_en_US, + arg.GetLabel(), dummyName); + return; + } ConvertBOZLiteralArg(arg, object.type.type()); if (auto *expr{arg.UnwrapExpr()}) { if (auto type{characteristics::TypeAndShape::Characterize( diff --git a/flang/test/Semantics/call26.f90 b/flang/test/Semantics/call26.f90 new file mode 100644 --- /dev/null +++ b/flang/test/Semantics/call26.f90 @@ -0,0 +1,12 @@ +! RUN: %python %S/test_errors.py %s %flang_fc1 +module m + contains + subroutine s(x) + integer, intent(in) :: x + end + subroutine s2 + !ERROR: Label '42' can't be associated with dummy argument 'x=' + call s(*42) + 42 stop + end +end module m