This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
PR26038 and the pre-gomp patch
- From: "THOMAS Paul Richard 169137" <paul dot richard dot thomas at cea dot fr>
- To: "Jakub Jelinek" <jakub at redhat dot com>
- Cc: <fortran at gcc dot gnu dot org>, <paulthomas2 at wanadoo dot fr>
- Date: Tue, 31 Jan 2006 14:13:57 +0100
- Subject: PR26038 and the pre-gomp patch
Jakub,
I just posted a comment on PR26038. ALLOCATE fails for assumed character length pointers because the TYPE_SIZE_UNIT is NULL. I wrote a quickie patch that you will find below; it passes the se.string_length to the library instead. However, your pre-gomp patch cures the problem. This is another reason to commit it, it seems to me.
How about the pre-gomp patch going to 4.2 and the quickie patch to 4.1?
Best regards
Paul
Comment on PR26038
==================
If you look at the code produced by this final example, the 2nd argument of
_gfc_allocate is null. This comes about because the TYPE_SIZE_UNIT that Jakub
hated me setting directly is a NULL_TREE. I suspect that his patch will fix
this. Otherwise, this works and will be submitted tonight:
Index: gcc/fortran/trans-stmt.c
===================================================================
--- gcc/fortran/trans-stmt.c (révision 110394)
+++ gcc/fortran/trans-stmt.c (copie de travail)
@@ -3254,8 +3254,12 @@
val = gfc_create_var (ppvoid_type_node, "ptr");
tmp = gfc_build_addr_expr (ppvoid_type_node, se.expr);
gfc_add_modify_expr (&se.pre, val, tmp);
-
- tmp = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (se.expr)));
+
+ tmp = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (se.expr)));
+
+ if (expr->ts.type == BT_CHARACTER && tmp == NULL_TREE)
+ tmp = se.string_length;
+
parm = gfc_chainon_list (NULL_TREE, val);
parm = gfc_chainon_list (parm, tmp);
parm = gfc_chainon_list (parm, pstat);
This results in the hidden charlen dummy argument being passed to the library
allocate.
Hah! I just undid the above and applied Jakub's patch; as I suspected it fixes
the bug and produces the following code:
foo (self, _self)
{
bit_size_type D.802;
<unnamed type> D.803;
D.802 = (bit_size_type) (<unnamed type>) _self * 8;
D.803 = (<unnamed type>) _self;
*self = 0B;
{
void * * ptr.0;
ptr.0 = (void * *) self;
_gfortran_allocate (ptr.0, (<unnamed type>) _self, 0);
}
{
struct __st_parameter_dt dt_parm.1;
dt_parm.1.common.filename = "pr26038.f90";
dt_parm.1.common.line = 10;
dt_parm.1.common.unit = 6;
dt_parm.1.common.flags = 128;
_gfortran_st_write (&dt_parm.1);
{
int4 D.801;
D.801 = _self;
_gfortran_transfer_integer (&dt_parm.1, &D.801, 4);
}
_gfortran_st_write_done (&dt_parm.1);
}
}
MAIN__ ()
{
char[1:10] * q;
char[1:5] * p;
foo (&p, 5);
foo (&q, 10);
}
I will email Jakub to let him know. Perhaps the trick will be to apply his
pre-gomp patch to 4.2 and mine to 4.1?
Paul