[PATCH,fortran]: fix part of PR 32600
Christopher D. Rickett
crickett@lanl.gov
Wed Jul 18 23:29:00 GMT 2007
hi all,
the attached updated patch for PR 32600 removes C_LOC from libgfortran.
bootstrapped and regtested on x86 and x86_64 linux with no new failures.
Chris
:ADDPATCH fortran:
2007-07-18 Christopher D. Rickett <crickett@lanl.gov>
PR fortran/32600
* trans-expr.c (gfc_conv_function_call): Inline C_LOC.
2007-07-18 Christopher D. Rickett <crickett@lanl.gov>
PR fortran/32600
* libgfortran/intrinsics/iso_c_binding.c: Remove C_LOC.
* libgfortran/intrinsics/iso_c_binding.h: Ditto.
* libgfortran/gfortran.map: Ditto.
On Wed, 18 Jul 2007, Tobias Burnus wrote:
> Hi Chris,
>
>> the attached patch addresses the C_LOC part of PR 32600, allowing for
>> C_LOC to be inlined.
>
> Currently (until 4.3.0 is released) we ignore binary compatibility of the library; thus you should remove the c_loc implementation from libgfortran/.
>
> Otherwise the patch is ok.
>
> Tobias
>
-------------- next part --------------
Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c (revision 126731)
+++ gcc/fortran/trans-expr.c (working copy)
@@ -2060,6 +2061,33 @@ gfc_conv_function_call (gfc_se * se, gfc
var = NULL_TREE;
len = NULL_TREE;
+ if (sym->from_intmod == INTMOD_ISO_C_BINDING
+ && sym->intmod_sym_id == ISOCBINDING_LOC)
+ {
+ if (arg->expr->rank == 0)
+ {
+ gfc_conv_expr_reference (se, arg->expr);
+ }
+ else
+ {
+ int f;
+ /* This is really the actual arg because no formal arglist is
+ created for C_LOC. */
+ fsym = arg->expr->symtree->n.sym;
+
+ /* We should want it to do g77 calling convention. */
+ f = (fsym != NULL)
+ && !(fsym->attr.pointer || fsym->attr.allocatable)
+ && fsym->as->type != AS_ASSUMED_SHAPE;
+ f = f || !sym->attr.always_explicit;
+
+ argss = gfc_walk_expr (arg->expr);
+ gfc_conv_array_parameter (se, arg->expr, argss, f);
+ }
+
+ return 0;
+ }
+
if (se->ss != NULL)
{
if (!sym->attr.elemental)
Index: libgfortran/intrinsics/iso_c_binding.c
===================================================================
--- libgfortran/intrinsics/iso_c_binding.c (revision 126731)
+++ libgfortran/intrinsics/iso_c_binding.c (working copy)
@@ -213,23 +234,6 @@ ISO_C_BINDING_PREFIX (c_associated_2) (v
}
-/* Return the C address of the given Fortran allocatable object. */
-
-void *
-ISO_C_BINDING_PREFIX (c_loc) (void *f90_obj)
-{
- if (f90_obj == NULL)
- {
- runtime_error ("C_LOC: Attempt to get C address for Fortran object"
- " that has not been allocated or associated");
- abort ();
- }
-
- /* The "C" address should be the address of the object in Fortran. */
- return f90_obj;
-}
-
-
/* Return the C address of the given Fortran procedure. This
routine is expected to return a derived type of type C_FUNPTR,
which represents the C address of the given Fortran object. */
Index: libgfortran/intrinsics/iso_c_binding.h
===================================================================
--- libgfortran/intrinsics/iso_c_binding.h (revision 126731)
+++ libgfortran/intrinsics/iso_c_binding.h (working copy)
@@ -64,7 +64,6 @@ 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 *);
-void *ISO_C_BINDING_PREFIX(c_loc) (void *);
void *ISO_C_BINDING_PREFIX(c_funloc) (void *);
#endif
Index: libgfortran/gfortran.map
===================================================================
--- libgfortran/gfortran.map (revision 126731)
+++ libgfortran/gfortran.map (working copy)
@@ -1016,10 +1016,18 @@ GFORTRAN_1.0 {
__iso_c_binding_c_f_pointer_r8;
__iso_c_binding_c_f_pointer_r10;
__iso_c_binding_c_f_pointer_r16;
+ __iso_c_binding_c_f_pointer_c4;
+ __iso_c_binding_c_f_pointer_c8;
+ __iso_c_binding_c_f_pointer_c10;
+ __iso_c_binding_c_f_pointer_c16;
+ __iso_c_binding_c_f_pointer_s0;
+ __iso_c_binding_c_f_pointer_l1;
+ __iso_c_binding_c_f_pointer_l2;
+ __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;
__iso_c_binding_c_funloc;
- __iso_c_binding_c_loc;
local:
*;
};
More information about the Fortran
mailing list