}
else
{
- if (tmp_sym->ts.type == BT_DERIVED || ts->type == BT_DERIVED)
- gfc_error ("Type declaration %qs at %L is not C "
- "interoperable but it is BIND(C)",
- tmp_sym->name, &(tmp_sym->declared_at));
+ if (tmp_sym->ts.type == BT_DERIVED || ts->type == BT_DERIVED
+ || tmp_sym->ts.type == BT_CLASS || ts->type == BT_CLASS)
+ {
+ gfc_error ("Type declaration %qs at %L is not C "
+ "interoperable but it is BIND(C)",
+ tmp_sym->name, &(tmp_sym->declared_at));
+ retval = false;
+ }
else if (warn_c_binding_type)
gfc_warning (OPT_Wc_binding_type, "Variable %qs at %L "
"may not be a C interoperable "
--- /dev/null
+! { dg-do compile }
+! PR fortran/95375 - ICE in add_use_op
+! Contributed by G.Steinmetz
+
+function f() result(n) bind(c) ! { dg-error "not C interoperable" }
+ class(*), allocatable :: n
+end
+program p
+ interface
+ function f() result(n) bind(c)
+ integer :: n
+ end
+ end interface
+ if ( f() /= 0 ) stop
+end
+
+! { dg-prune-output "Type mismatch" }