Skip to content

[flang] Reduce implicit interface compatibility warnings due to length #69385

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
Oct 31, 2023
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
13 changes: 11 additions & 2 deletions flang/lib/Evaluate/characteristics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,15 @@ bool DummyDataObject::IsCompatibleWith(
}
return false;
}
if (!type.type().IsTkLenCompatibleWith(actual.type.type())) {
// Treat deduced dummy character type as if it were assumed-length character
// to avoid useless "implicit interfaces have distinct type" warnings from
// CALL FOO('abc'); CALL FOO('abcd').
bool deducedAssumedLength{type.type().category() == TypeCategory::Character &&
attrs.test(Attr::DeducedFromActual)};
bool compatibleTypes{deducedAssumedLength
? type.type().IsTkCompatibleWith(actual.type.type())
: type.type().IsTkLenCompatibleWith(actual.type.type())};
if (!compatibleTypes) {
if (whyNot) {
*whyNot = "incompatible dummy data object types: "s +
type.type().AsFortran() + " vs " + actual.type.type().AsFortran();
Expand All @@ -314,7 +322,8 @@ bool DummyDataObject::IsCompatibleWith(
}
return false;
}
if (type.type().category() == TypeCategory::Character) {
if (type.type().category() == TypeCategory::Character &&
!deducedAssumedLength) {
if (actual.type.type().IsAssumedLengthCharacter() !=
type.type().IsAssumedLengthCharacter()) {
if (whyNot) {
Expand Down
2 changes: 2 additions & 0 deletions flang/test/Semantics/call35.f90
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
! RUN: %python %S/test_errors.py %s %flang_fc1 -Werror
subroutine s1
call ext(1, 2)
call myerror('abc')
end

subroutine s2
!WARNING: Reference to the procedure 'ext' has an implicit interface that is distinct from another reference: distinct numbers of dummy arguments
call ext(1.)
call myerror('abcd') ! don't warn about distinct lengths
end

subroutine s3
Expand Down