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 @@ -719,7 +719,8 @@ if (actual) { CheckExplicitInterfaceArg( *actual, dummy, proc, localContext, scope, intrinsic); - } else if (!dummy.IsOptional()) { + } else if (!dummy.IsOptional() && + !std::holds_alternative(dummy.u)) { if (dummy.name.empty()) { messages.Say( "Dummy argument #%d is not OPTIONAL and is not associated with " diff --git a/flang/test/Semantics/altreturn06.f90 b/flang/test/Semantics/altreturn06.f90 new file mode 100644 --- /dev/null +++ b/flang/test/Semantics/altreturn06.f90 @@ -0,0 +1,11 @@ +! RUN: %S/test_errors.sh %s %t %f18 +! Test argument passing for internal and external subprograms +! Both of the following are OK + call extSubprogram (*100) + call intSubprogram (*100) +100 PRINT *,'First alternate return' +contains + subroutine intSubprogram(*) + return(1) + end subroutine +end