aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2022-12-20 21:17:08 +0100
committerHarald Anlauf <anlauf@gmx.de>2022-12-20 22:24:01 +0100
commitaed5584ff6891560dc567e54517b9722dadc503e (patch)
tree010a8bb9d5343f4744c7b3a4843f4056de9154eb /gcc/fortran
parenta6504f13a0509f3937bdcdf63bf76bed7d880b72 (diff)
downloadgcc-aed5584ff6891560dc567e54517b9722dadc503e.zip
gcc-aed5584ff6891560dc567e54517b9722dadc503e.tar.gz
gcc-aed5584ff6891560dc567e54517b9722dadc503e.tar.bz2
Fortran: a C interoperable function cannot have the CLASS attribute [PR95375]
gcc/fortran/ChangeLog: PR fortran/95375 * decl.cc (verify_bind_c_sym): Extend interoperability check to CLASS variables. gcc/testsuite/ChangeLog: PR fortran/95375 * gfortran.dg/bind_c_procs_4.f90: New test.
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/decl.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
index 1562dc2..e593518 100644
--- a/gcc/fortran/decl.cc
+++ b/gcc/fortran/decl.cc
@@ -5998,10 +5998,14 @@ verify_bind_c_sym (gfc_symbol *tmp_sym, gfc_typespec *ts,
}
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 "