diff --git a/flang/lib/Evaluate/characteristics.cpp b/flang/lib/Evaluate/characteristics.cpp index ac61e72f428a9..3074fc0516b46 100644 --- a/flang/lib/Evaluate/characteristics.cpp +++ b/flang/lib/Evaluate/characteristics.cpp @@ -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(); @@ -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) { diff --git a/flang/test/Semantics/call35.f90 b/flang/test/Semantics/call35.f90 index ddcd64cec6c43..ff819481226d6 100644 --- a/flang/test/Semantics/call35.f90 +++ b/flang/test/Semantics/call35.f90 @@ -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