This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Patch, Fortran][RFC] Re-add libgfortran's c_f_procpointer (PR 38871)
- From: Tobias Burnus <burnus at net-b dot de>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Sat, 17 Jan 2009 10:56:57 +0100
- Subject: [Patch, Fortran][RFC] Re-add libgfortran's c_f_procpointer (PR 38871)
Hi all,
when Chris added Bind(C) support he also included the libgfortran
function C_F_PROCPOINTER, which simply casted a pointer. As
procedure pointers were not supported back then, the function was
unused.
I removed the procedure from libgfortran after 4.3.0, when replacing
c_f_pointer (w/o SHAPE=) and c_f_procpointer with doing a proper
pointer assignment on tree level. As the first procedure pointer
patch was 2 months later, C_F_PROCPOINTER could not be used by
using "CALL C_F_PROCPOINTER" with procedure pointer arguments
(the "type(c_procptr)" data type existed but not the Fortran
proc pointer datatype).
Using the following program,
use iso_c_binding
type(c_ptr) :: fun
integer, pointer :: bar
call c_f_procpointer(fun,bar)
end
one could call c_f_procpointer in 4.3 but the symbol generated was
__iso_c_binding_c_f_procpointer_i4
which does never existed (only __iso_c_binding_c_f_procpointer existed).
Thus I still maintain what I wrote almost a year ago, when I submitted
the removal patch:
"As c_f_procpointer was never callable, I could remove it from the library."
Thus I believe one can close the bug as WONTFIX. Alternatively, one can
add the following patch, which re-adds the symbol.
Jakub, who has opened the P1 regression, writes there:
"I'd say re-adding that symbol until you change libgfortran ABI wouldn't hurt
anything, but if you can prove no program could ever use it except for
referencing directly that symbol, I guess I can live with a WONTFIX too."
Tobias
2009-01-17 Tobias Burnus <burnus@net-b.de>
PR fortran/38871
* intrinsics/iso_c_binding.c (c_f_procpointer): Re-add.
* intrinsics/iso_c_binding.h (c_f_procpointer): Re-add.
* gfortran.map (c_f_procpointer): Re-add.
Index: libgfortran/intrinsics/iso_c_binding.c
===================================================================
--- libgfortran/intrinsics/iso_c_binding.c (Revision 143458)
+++ libgfortran/intrinsics/iso_c_binding.c (Arbeitskopie)
@@ -180,3 +180,17 @@ ISO_C_BINDING_PREFIX (c_f_pointer_d0) (v
| (GFC_DTYPE_DERIVED << GFC_DTYPE_TYPE_SHIFT);
}
}
+
+
+/* Unused function, initially planed for procedure pointers but never
+ used for it; cf. PR 38871. TODO: Remove when bumping the library
+ version. */
+
+void
+ISO_C_BINDING_PREFIX (c_f_procpointer) (void *c_ptr_in,
+ gfc_array_void *f_ptr_out)
+{
+ GFC_DESCRIPTOR_DATA(f_ptr_out) = c_ptr_in;
+}
+
+
Index: libgfortran/intrinsics/iso_c_binding.h
===================================================================
--- libgfortran/intrinsics/iso_c_binding.h (Revision 143458)
+++ libgfortran/intrinsics/iso_c_binding.h (Arbeitskopie)
@@ -41,6 +41,9 @@ typedef struct c_ptr
}
c_ptr_t;
+/* Unused structure, initially planed for procedure pointers but never
+ used for it. TODO: Remove (when bumping the library
+ version?). */
typedef struct c_funptr
{
void *c_address;
@@ -57,4 +60,9 @@ void ISO_C_BINDING_PREFIX(c_f_pointer_u0
void ISO_C_BINDING_PREFIX(c_f_pointer_d0) (void *, gfc_array_void *,
const array_t *);
+/* Unused function, initially planed for procedure pointers but never
+ used for it; cf. PR 38871. TODO: Remove when bumping the library
+ version. */
+void ISO_C_BINDING_PREFIX(c_f_procpointer) (void *, gfc_array_void *);
+
#endif
Index: libgfortran/gfortran.map
===================================================================
--- libgfortran/gfortran.map (Revision 143458)
+++ libgfortran/gfortran.map (Arbeitskopie)
@@ -1026,6 +1026,7 @@ GFORTRAN_1.0 {
__iso_c_binding_c_f_pointer_l4;
__iso_c_binding_c_f_pointer_l8;
__iso_c_binding_c_f_pointer_u0;
+ __iso_c_binding_c_f_procpointer;
local:
*;
};