[Patch, fortran] PR29396 PR29606 PR30625 and PR30871 - subreference array pointers.
Tobias Burnus
burnus@net-b.de
Mon Sep 10 18:37:00 GMT 2007
Paul Thomas wrote:
> It is my opinion that this patch is ready for 4.3 simply because it
> provides an extra functionality that is ringfenced by specific tests.
> Such pointer assignements, at present, either lead to ICEs or wrong
> code. Hence, even if it is not in its final form, it will not break
> anything, whilst filling in the missing f95 feature.
I looked at the patch plus at the following, which I extracted from your
follow up:
http://gcc.gnu.org/ml/fortran/2007-09/msg00175.html
As the diff looks quite different, I'm not 100% sure that I got it right.
@@ -4124,10 +4120,12 @@ gfc_trans_assignment (gfc_expr * expr1,
}
/* Special case copying one array to another. */
- if (copyable_array_p (expr1)
- && copyable_array_p (expr2)
- && gfc_compare_types (&expr1->ts, &expr2->ts)
- && !gfc_check_dependency (expr1, expr2, 0))
+ if (expr1->expr_type == EXPR_VARIABLE
+ && copyable_array_p (expr1)
+ && gfc_full_array_ref_p (expr1->ref)
+ && !expr1->ref->next
+ && expr2->expr_type == EXPR_ARRAY
+ && gfc_compare_types (&expr1->ts, &expr2->ts))
{
tmp = gfc_trans_array_copy (expr1, expr2);
if (tmp)
Looking at all the failures I got, I'm almost positive that I have not got it right. :-(
Now to the patch:
@@ -206,7 +206,9 @@ gfc_get_expr_charlen (gfc_expr *e)
default:
/* We should never got substring references here. These will be
broken down by the scalarizer. */
- gcc_unreachable ();
+ if (is_subref_array (e))
+ length = e->symtree->n.sym->ts.cl->backend_decl;
+ break;
Shouldn't one update the comment?
@@ -321,7 +323,28 @@ gfc_build_array_ref (tree base, tree off
+ if (decl && (TREE_CODE (decl) == FIELD_DECL
+ || TREE_CODE (decl) == VAR_DECL
+ || TREE_CODE (decl) == PARM_DECL)
The indenting looks wrong.
Otherwise, the patch seems to be ok. (It would great if someone else would also review the patch!)
Note: I still get a ICE with the test case from PR29606:
internal compiler error: in gfc_get_element_type, at fortran/trans-types.c:935
(This might be because I wrongly applied the follow-up patch; or it might be not.)
For the example of PR30871 I get an ICE (segmentation fault):
==23839== Invalid read of size 8
==23839== at 0x4985B6: gfc_get_expr_charlen (trans-expr.c:210)
==23839== by 0x487115: gfc_conv_expr_descriptor (trans-array.c:4614)
==23839== by 0x49CF3D: gfc_trans_pointer_assignment (trans-expr.c:3465)
And if I try to regression test, There are legions of failures.
gfortran.dg/alloc_comp_constructor_1.f90:102: internal compiler error: Segmentation fault
==31732== Invalid read of size 8
==31732== at 0x49C380: gfc_trans_assignment (trans-expr.c:3824)
==31732== by 0x47FE80: gfc_trans_code (trans.c:993)
==31732== by 0x494E42: gfc_generate_function_code (trans-decl.c:3277)
gfortran.dg/allocatable_dummy_1.f90:28: internal compiler error: Segmentation fault
==31752== Invalid read of size 8
==31752== at 0x49C380: gfc_trans_assignment (trans-expr.c:3824)
==31752== by 0x47FE80: gfc_trans_code (trans.c:993)
==31752== by 0x494E42: gfc_generate_function_code (trans-decl.c:3277)
etc.
Tobias
More information about the Fortran
mailing list