/* We have to make sure that any param to a bind(c) routine does
not have the allocatable, pointer, or optional attributes,
according to J3/04-007, section 5.1. */
- if (sym->attr.allocatable == 1)
- {
- gfc_error ("Variable '%s' at %L cannot have the "
- "ALLOCATABLE attribute because procedure '%s'"
- " is BIND(C)", sym->name, &(sym->declared_at),
- sym->ns->proc_name->name);
- retval = false;
- }
+ if (sym->attr.allocatable == 1
+ && !gfc_notify_std (GFC_STD_F2008_TS, "Variable '%s' at %L with "
+ "ALLOCATABLE attribute in procedure '%s' "
+ "with BIND(C)", sym->name,
+ &(sym->declared_at),
+ sym->ns->proc_name->name))
+ retval = false;
+
+ if (sym->attr.pointer == 1
+ && !gfc_notify_std (GFC_STD_F2008_TS, "Variable '%s' at %L with "
+ "POINTER attribute in procedure '%s' "
+ "with BIND(C)", sym->name,
+ &(sym->declared_at),
+ sym->ns->proc_name->name))
+ retval = false;
- if (sym->attr.pointer == 1)
+ if ((sym->attr.allocatable || sym->attr.pointer) && !sym->as)
{
- gfc_error ("Variable '%s' at %L cannot have the "
- "POINTER attribute because procedure '%s'"
- " is BIND(C)", sym->name, &(sym->declared_at),
+ gfc_error ("Scalar variable '%s' at %L with POINTER or "
+ "ALLOCATABLE in procedure '%s' with BIND(C) is not yet"
+ " supported", sym->name, &(sym->declared_at),
sym->ns->proc_name->name);
retval = false;
}
--- /dev/null
+! { dg-do compile }
+! { dg-options "-std=f2008ts" }
+!
+! Contributed by Reinhold Bader
+!
+use iso_c_binding
+type, bind(C) :: cstruct
+ integer :: i
+end type
+interface
+ subroutine psub(this, that) bind(c, name='Psub')
+ import :: c_float, cstruct
+ real(c_float), pointer :: this(:)
+ type(cstruct), allocatable :: that(:)
+ end subroutine psub
+ end interface
+end
--- /dev/null
+! { dg-do compile }
+! { dg-options "-std=f2008" }
+!
+! Contributed by Reinhold Bader
+!
+use iso_c_binding
+type, bind(C) :: cstruct
+ integer :: i
+end type
+interface
+ subroutine psub(this) bind(c, name='Psub') ! { dg-error "TS 29113: Variable 'this' at .1. with POINTER attribute in procedure 'psub' with BIND.C." }
+ import :: c_float, cstruct
+ real(c_float), pointer :: this(:)
+ end subroutine psub
+ subroutine psub2(that) bind(c, name='Psub2') ! { dg-error "TS 29113: Variable 'that' at .1. with ALLOCATABLE attribute in procedure 'psub2' with BIND.C." }
+ import :: c_float, cstruct
+ type(cstruct), allocatable :: that(:)
+ end subroutine psub2
+ end interface
+end