public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/45211] New: C interoperable error when compiling BIND(C) function in a module.
@ 2010-08-06 17:13 brtnfld at hdfgroup dot org
2010-08-06 17:26 ` [Bug fortran/45211] " dominiq at lps dot ens dot fr
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: brtnfld at hdfgroup dot org @ 2010-08-06 17:13 UTC (permalink / raw)
To: gcc-bugs
gfortran (all versions 4.2-4.5) reports the error when trying to compile code
below:
Error: Type 'link_info' at (1) is a parameter to the BIND(C) procedure
'liter_cb' but is not C interoperable because derived type 'info_t' is not C
interoperable
when I remove the module and compile just the function it compiles fine. info_t
is interoperable with C
MODULE liter_cb_mod
USE ISO_C_BINDING
CONTAINS
FUNCTION liter_cb(link_info) bind(C)
USE ISO_C_BINDING
IMPLICIT NONE
INTEGER(c_int) liter_cb
TYPE, bind(C) :: info_t
INTEGER(c_int) :: type
END TYPE info_t
TYPE(info_t) :: link_info
liter_cb = 0
END FUNCTION liter_cb
END MODULE liter_cb_mod
--
Summary: C interoperable error when compiling BIND(C) function in
a module.
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: brtnfld at hdfgroup dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45211
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/45211] C interoperable error when compiling BIND(C) function in a module.
2010-08-06 17:13 [Bug fortran/45211] New: C interoperable error when compiling BIND(C) function in a module brtnfld at hdfgroup dot org
@ 2010-08-06 17:26 ` dominiq at lps dot ens dot fr
2010-08-09 15:03 ` brtnfld at hdfgroup dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: dominiq at lps dot ens dot fr @ 2010-08-06 17:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from dominiq at lps dot ens dot fr 2010-08-06 17:26 -------
Confirmed also with trunk.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45211
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/45211] C interoperable error when compiling BIND(C) function in a module.
2010-08-06 17:13 [Bug fortran/45211] New: C interoperable error when compiling BIND(C) function in a module brtnfld at hdfgroup dot org
2010-08-06 17:26 ` [Bug fortran/45211] " dominiq at lps dot ens dot fr
@ 2010-08-09 15:03 ` brtnfld at hdfgroup dot org
2010-08-14 16:25 ` burnus at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: brtnfld at hdfgroup dot org @ 2010-08-09 15:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from brtnfld at hdfgroup dot org 2010-08-09 15:02 -------
If the type declaration is moved to the module scope the code compiles.
MODULE liter_cb_mod
USE ISO_C_BINDING
TYPE, BIND(C) :: MYFTYPE
INTEGER(C_INT) :: I, J
REAL(C_FLOAT) :: S
END TYPE MYFTYPE
CONTAINS
FUNCTION liter_cb() bind(C)
USE ISO_C_BINDING
IMPLICIT NONE
INTEGER(c_int) liter_cb
TYPE(MYFTYPE) :: link_info
liter_cb = 0
END FUNCTION liter_cb
END MODULE liter_cb_mod
There was a discussion about the matter in comp.lang.fortran under the topic
"BIND(C) functions in a module error" as to the source of the problem. Since
there seems to be a work around I downgraded the severity.
--
brtnfld at hdfgroup dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|critical |normal
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45211
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/45211] C interoperable error when compiling BIND(C) function in a module.
2010-08-06 17:13 [Bug fortran/45211] New: C interoperable error when compiling BIND(C) function in a module brtnfld at hdfgroup dot org
2010-08-06 17:26 ` [Bug fortran/45211] " dominiq at lps dot ens dot fr
2010-08-09 15:03 ` brtnfld at hdfgroup dot org
@ 2010-08-14 16:25 ` burnus at gcc dot gnu dot org
2010-08-15 16:21 ` burnus at gcc dot gnu dot org
2010-08-15 16:23 ` burnus at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-08-14 16:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from burnus at gcc dot gnu dot org 2010-08-14 16:24 -------
Cf.
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/887251d8cd64eb02
Lightly tested patch. The ts.is_c_interop is only set when via
verify_bind_c_derived_type, which is called by resolve.c - and thus comes too
late.
I am not sure whether this now allows DT which are not BIND(C) and whether one
thus should add an !attr.resolved, but I assume that incompatibilities between
the BIND(C) attribute for the DT and the actual DT will be found at resolution
time. Thus, the patch should be fine.
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c (Revision 163239)
+++ gcc/fortran/decl.c (Arbeitskopie)
@@ -991,7 +991,7 @@ verify_c_interop_param (gfc_symbol *sym)
/* Make personalized messages to give better feedback. */
if (sym->ts.type == BT_DERIVED)
gfc_error ("Type '%s' at %L is a parameter to the BIND(C) "
- " procedure '%s' but is not C interoperable "
+ "procedure '%s' but is not C interoperable "
"because derived type '%s' is not C interoperable",
sym->name, &(sym->declared_at),
sym->ns->proc_name->name,
@@ -3612,7 +3612,8 @@ gfc_try
verify_c_interop (gfc_typespec *ts)
{
if (ts->type == BT_DERIVED && ts->u.derived != NULL)
- return (ts->u.derived->ts.is_c_interop ? SUCCESS : FAILURE);
+ return (ts->u.derived->ts.is_c_interop || ts->u.derived->attr.is_bind_c)
+ ? SUCCESS : FAILURE;
else if (ts->is_c_interop != 1)
return FAILURE;
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45211
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/45211] C interoperable error when compiling BIND(C) function in a module.
2010-08-06 17:13 [Bug fortran/45211] New: C interoperable error when compiling BIND(C) function in a module brtnfld at hdfgroup dot org
` (2 preceding siblings ...)
2010-08-14 16:25 ` burnus at gcc dot gnu dot org
@ 2010-08-15 16:21 ` burnus at gcc dot gnu dot org
2010-08-15 16:23 ` burnus at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-08-15 16:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from burnus at gcc dot gnu dot org 2010-08-15 16:21 -------
Subject: Bug 45211
Author: burnus
Date: Sun Aug 15 16:20:56 2010
New Revision: 163264
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163264
Log:
2010-08-15 Tobias Burnus <burnus@net-b.de>
PR fortran/45211
* decl.c (verify_c_interop_param): Remove superfluous space (" ").
(verify_c_interop): Handle unresolved DT with bind(C).
2010-08-15 Tobias Burnus <burnus@net-b.de>
PR fortran/45211
* gfortran.dg/bind_c_usage_21.f90: New.
* gfortran.dg/bind_c_dts_3.f03: Update dg-error.
Added:
trunk/gcc/testsuite/gfortran.dg/bind_c_usage_21.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/decl.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gfortran.dg/bind_c_dts_3.f03
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45211
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/45211] C interoperable error when compiling BIND(C) function in a module.
2010-08-06 17:13 [Bug fortran/45211] New: C interoperable error when compiling BIND(C) function in a module brtnfld at hdfgroup dot org
` (3 preceding siblings ...)
2010-08-15 16:21 ` burnus at gcc dot gnu dot org
@ 2010-08-15 16:23 ` burnus at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-08-15 16:23 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from burnus at gcc dot gnu dot org 2010-08-15 16:23 -------
FIXED on the trunk (4.6). Thanks for the bug report!
(I do not intent to backport the patch to the 4.4/4.5 branch; tell me if you
think it should be applied there as well.)
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45211
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-08-15 16:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-06 17:13 [Bug fortran/45211] New: C interoperable error when compiling BIND(C) function in a module brtnfld at hdfgroup dot org
2010-08-06 17:26 ` [Bug fortran/45211] " dominiq at lps dot ens dot fr
2010-08-09 15:03 ` brtnfld at hdfgroup dot org
2010-08-14 16:25 ` burnus at gcc dot gnu dot org
2010-08-15 16:21 ` burnus at gcc dot gnu dot org
2010-08-15 16:23 ` burnus at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).