"An interface name with BIND attribute must be specified if the BIND attribute is specified in a procedure declaration statement"_err_en_US);
context_.SetError(symbol);
}
- }
- if (const auto *derived{symbol.detailsIf<DerivedTypeDetails>()}) {
+ } else if (const auto *derived{symbol.detailsIf<DerivedTypeDetails>()}) {
if (derived->sequence()) { // C1801
messages_.Say(symbol.name(),
"A derived type with the BIND attribute cannot have the SEQUENCE attribute"_err_en_US);
"A derived type with the BIND attribute cannot have a type bound procedure"_err_en_US);
context_.SetError(symbol);
break;
+ } else if (IsAllocatableOrPointer(*component)) { // C1806
+ messages_.Say(symbol.name(),
+ "A derived type with the BIND attribute cannot have a pointer or allocatable component"_err_en_US);
+ context_.SetError(symbol);
+ break;
+ } else if (component->GetType() && component->GetType()->AsDerived() &&
+ !component->GetType()->AsDerived()->typeSymbol().attrs().test(
+ Attr::BIND_C)) {
+ messages_.Say(component->GetType()->AsDerived()->typeSymbol().name(),
+ "The component of the interoperable derived type must have the BIND attribute"_err_en_US);
+ context_.SetError(symbol);
+ break;
}
}
}
integer(kind=int64) :: __address
end type
- type :: __builtin_c_funptr
+ type, bind(c) :: __builtin_c_funptr
integer(kind=int64) :: __address
end type
type, bind(c) :: t5
end type
+ ! ERROR: A derived type with the BIND attribute cannot have a pointer or allocatable component
+ type, bind(c) :: t6
+ integer, pointer :: x
+ end type
+
+ ! ERROR: A derived type with the BIND attribute cannot have a pointer or allocatable component
+ type, bind(c) :: t7
+ integer, allocatable :: y
+ end type
+
+ ! ERROR: The component of the interoperable derived type must have the BIND attribute
+ type :: t8
+ integer :: x
+ end type
+
+ type, bind(c) :: t9
+ type(t8) :: y
+ integer :: z
+ end type
+
end