Commit f76b96c2 by Steven G. Kargl

symbol.c (verify_bind_c_derived_type): Accept BIND(C) on an empty derived type.

2010-11-10  Steven G. Kargl <kargl@gcc.gnu.org>

	* symbol.c (verify_bind_c_derived_type):  Accept BIND(C) on an empty
	derived type.

2010-11-10  Steven G. Kargl <kargl@gcc.gnu.org>

	* gfortran.dg/empty_derived_type.f90: New test.

From-SVN: r166633
parent a9c64730
2010-11-11 Steven G. Kargl <kargl@gcc.gnu.org>
* symbol.c (verify_bind_c_derived_type): Accept BIND(C) on an empty
derived type.
2010-11-11 Jan Hubicka <jh@suse.cz>
* options.c (gfc_post_options): Remove flag_whopr.
......
......@@ -3592,14 +3592,25 @@ verify_bind_c_derived_type (gfc_symbol *derived_sym)
curr_comp = derived_sym->components;
/* TODO: is this really an error? */
/* Fortran 2003 allows an empty derived type. C99 appears to disallow an
empty struct. Section 15.2 in Fortran 2003 states: "The following
subclauses define the conditions under which a Fortran entity is
interoperable. If a Fortran entity is interoperable, an equivalent
entity may be defined by means of C and the Fortran entity is said
to be interoperable with the C entity. There does not have to be such
an interoperating C entity."
*/
if (curr_comp == NULL)
{
gfc_error ("Derived type '%s' at %L is empty",
derived_sym->name, &(derived_sym->declared_at));
return FAILURE;
gfc_warning ("Derived type '%s' with BIND(C) attribute at %L is empty, "
"and may be inaccessible by the C companion processor",
derived_sym->name, &(derived_sym->declared_at));
derived_sym->ts.is_c_interop = 1;
derived_sym->attr.is_bind_c = 1;
return SUCCESS;
}
/* Initialize the derived type as being C interoperable.
If we find an error in the components, this will be set false. */
derived_sym->ts.is_c_interop = 1;
......
2010-11-11 Steven G. Kargl <kargl@gcc.gnu.org>
* gfortran.dg/empty_derived_type.f90: New test.
2010-11-11 Tobias Burnus <burnus@net-b.de>
PR fortran/46413
......
! { dg-do compile }
module stuff
implicit none
type, bind(C) :: junk ! { dg-warning "may be inaccessible by the C companion" }
! Empty!
end type junk
end module stuff
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment