gcc/fortran/ChangeLog:
PR fortran/85877
* resolve.cc (resolve_fl_procedure): Check for an explicit interface
of procedures with the BIND(C) attribute (F2018:15.4.2.2).
gcc/testsuite/ChangeLog:
PR fortran/85877
* gfortran.dg/pr85877.f90: New test.
}
}
}
+
+ /* F2018:15.4.2.2 requires an explicit interface for procedures with the
+ BIND(C) attribute. */
+ if (sym->attr.is_bind_c && sym->attr.if_source == IFSRC_UNKNOWN)
+ {
+ gfc_error ("Interface of %qs at %L must be explicit",
+ sym->name, &sym->declared_at);
+ return false;
+ }
+
return true;
}
--- /dev/null
+! { dg-do compile }
+! PR fortran/85877
+! A procedure with the bind(c) attribute shall have an explicit interface
+! Contributed by G. Steinmetz
+
+function f() bind(c)
+ f = 42.
+end
+
+subroutine p
+ bind(c) f ! { dg-error "must be explicit" }
+ x = f()
+end
+
+function g() bind(c)
+ g = 42.
+end
+
+subroutine s
+ interface
+ function g() bind(c)
+ end function g
+ end interface
+ x = g()
+end