Skip to content

[flang] Don't convert actual arguments when interface is implicit #89795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions flang/lib/Semantics/check-call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1929,6 +1929,7 @@ bool CheckArguments(const characteristics::Procedure &proc,
bool explicitInterface{proc.HasExplicitInterface()};
evaluate::FoldingContext foldingContext{context.foldingContext()};
parser::ContextualMessages &messages{foldingContext.messages()};
bool allowArgumentConversions{true};
if (!explicitInterface || treatingExternalAsImplicit) {
parser::Messages buffer;
{
Expand All @@ -1945,11 +1946,12 @@ bool CheckArguments(const characteristics::Procedure &proc,
}
return false; // don't pile on
}
allowArgumentConversions = false;
}
if (explicitInterface) {
auto buffer{CheckExplicitInterface(proc, actuals, context, &scope,
intrinsic, /*allowArgumentConversions=*/true, /*extentErrors=*/true,
ignoreImplicitVsExplicit)};
intrinsic, allowArgumentConversions,
/*extentErrors=*/true, ignoreImplicitVsExplicit)};
if (!buffer.empty()) {
if (treatingExternalAsImplicit) {
if (auto *msg{messages.Say(
Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Semantics/expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2989,8 +2989,8 @@ void ExpressionAnalyzer::Analyze(const parser::CallStmt &callStmt) {
for (const auto &arg : actualArgList) {
analyzer.Analyze(arg, true /* is subroutine call */);
}
auto chevrons{AnalyzeChevrons(callStmt)};
if (!analyzer.fatalErrors() && chevrons) {
if (auto chevrons{AnalyzeChevrons(callStmt)};
chevrons && !analyzer.fatalErrors()) {
if (std::optional<CalleeAndArguments> callee{
GetCalleeAndArguments(std::get<parser::ProcedureDesignator>(call.t),
analyzer.GetActuals(), true /* subroutine */)}) {
Expand Down
16 changes: 16 additions & 0 deletions flang/test/Semantics/arg-convert.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
!RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
!Ensure that argument conversion does not take place when the procedure
!interface is implicit at the point of call, even when the interface
!is known due because the procedure's definition is in the same source file.

subroutine test
!CHECK: warning: If the procedure's interface were explicit, this reference would be in error
!CHECK: because: Actual argument type 'INTEGER(8)' is not compatible with dummy argument type 'INTEGER(4)'
!CHECK: CALL samesourcefile((1_8))
call sameSourceFile((1_8))
!CHECK: CALL somewhereelse((2_8))
call somewhereElse((2_8))
end

subroutine sameSourceFile(n)
end