Skip to content
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
19 changes: 10 additions & 9 deletions flang/lib/Evaluate/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2849,15 +2849,16 @@ IntrinsicProcTable::Implementation::HandleC_F_Pointer(
"FPTR= argument to C_F_POINTER() may not have a deferred type parameter"_err_en_US);
} else if (type->category() == TypeCategory::Derived) {
if (context.languageFeatures().ShouldWarn(
common::UsageWarning::Interoperability)) {
if (type->IsUnlimitedPolymorphic()) {
context.messages().Say(common::UsageWarning::Interoperability, at,
"FPTR= argument to C_F_POINTER() should not be unlimited polymorphic"_warn_en_US);
} else if (!type->GetDerivedTypeSpec().typeSymbol().attrs().test(
semantics::Attr::BIND_C)) {
context.messages().Say(common::UsageWarning::Interoperability, at,
"FPTR= argument to C_F_POINTER() should not have a derived type that is not BIND(C)"_warn_en_US);
}
common::UsageWarning::Interoperability) &&
type->IsUnlimitedPolymorphic()) {
context.messages().Say(common::UsageWarning::Interoperability, at,
"FPTR= argument to C_F_POINTER() should not be unlimited polymorphic"_warn_en_US);
} else if (!type->GetDerivedTypeSpec().typeSymbol().attrs().test(
semantics::Attr::BIND_C) &&
context.languageFeatures().ShouldWarn(
common::UsageWarning::Portability)) {
context.messages().Say(common::UsageWarning::Portability, at,
"FPTR= argument to C_F_POINTER() should not have a derived type that is not BIND(C)"_port_en_US);
}
} else if (!IsInteroperableIntrinsicType(
*type, &context.languageFeatures())
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Semantics/c_f_pointer.f90
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ program test
call c_f_pointer(scalarC, multiDimIntF, shape=rankTwoArray)
!WARNING: FPTR= argument to C_F_POINTER() should not be unlimited polymorphic
call c_f_pointer(scalarC, unlimited)
!WARNING: FPTR= argument to C_F_POINTER() should not have a derived type that is not BIND(C)
!PORTABILITY: FPTR= argument to C_F_POINTER() should not have a derived type that is not BIND(C)
call c_f_pointer(scalarC, notBindC)
!WARNING: FPTR= argument to C_F_POINTER() should not have the non-interoperable character length CHARACTER(KIND=1,LEN=2_8)
call c_f_pointer(scalarC, c2ptr)
Expand Down
Loading