diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp --- a/flang/lib/Semantics/check-declarations.cpp +++ b/flang/lib/Semantics/check-declarations.cpp @@ -426,6 +426,17 @@ " of a module"_err_en_US, symbol.name()); } + if (IsProcedure(symbol) && !symbol.HasExplicitInterface()) { + if (IsAllocatable(symbol)) { + messages_.Say( + "Procedure '%s' may not be ALLOCATABLE without an explicit interface"_err_en_US, + symbol.name()); + } else if (symbol.Rank() > 0) { + messages_.Say( + "Procedure '%s' may not be an array without an explicit interface"_err_en_US, + symbol.name()); + } + } } void CheckHelper::CheckCommonBlock(const Symbol &symbol) { @@ -916,7 +927,7 @@ } CheckPassArg(symbol, details.procInterface(), details); } - if (symbol.attrs().test(Attr::POINTER)) { + if (IsPointer(symbol)) { CheckPointerInitialization(symbol); if (const Symbol * interface{details.procInterface()}) { const Symbol &ultimate{interface->GetUltimate()}; @@ -936,7 +947,7 @@ symbol.name()); // C1517 } } - } else if (symbol.attrs().test(Attr::SAVE)) { + } else if (IsSave(symbol)) { messages_.Say( "Procedure '%s' with SAVE attribute must also have POINTER attribute"_err_en_US, symbol.name()); diff --git a/flang/test/Semantics/call05.f90 b/flang/test/Semantics/call05.f90 --- a/flang/test/Semantics/call05.f90 +++ b/flang/test/Semantics/call05.f90 @@ -121,7 +121,9 @@ module m2 + !ERROR: Procedure 't3' may not be ALLOCATABLE without an explicit interface character(len=10), allocatable :: t1, t2, t3, t4 + !ERROR: Procedure 't6' may not be ALLOCATABLE without an explicit interface character(len=:), allocatable :: t5, t6, t7, t8(:) character(len=10), pointer :: p1 diff --git a/flang/test/Semantics/resolve20.f90 b/flang/test/Semantics/resolve20.f90 --- a/flang/test/Semantics/resolve20.f90 +++ b/flang/test/Semantics/resolve20.f90 @@ -21,6 +21,7 @@ procedure(h) :: i procedure(forward) :: j !ERROR: 'bad1' must be an abstract interface or a procedure with an explicit interface + !ERROR: Procedure 'k1' may not be an array without an explicit interface procedure(bad1) :: k1 !ERROR: 'bad2' must be an abstract interface or a procedure with an explicit interface procedure(bad2) :: k2