Summary: | [OOP] gimplification failed for polymorphic MOVE_ALLOC | ||
---|---|---|---|
Product: | gcc | Reporter: | Dominique d'Humieres <dominiq> |
Component: | fortran | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | burnus, janus |
Priority: | P3 | Keywords: | ice-on-valid-code |
Version: | 4.7.0 | ||
Target Milestone: | 4.7.0 | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2012-01-24 00:00:00 | |
Attachments: | Draft patch for trans-intrinsic.c |
Description
Dominique d'Humieres
2012-01-23 17:14:00 UTC
(In reply to comment #0) > The code is accepted by trunk r183357. And it crashes in the same way with 4.7.0 2012-01-18 trunk revision 183273. (In any case it is not a (real) regression as GCC 4.6 didn't support polymorphic arrays.) > And it crashes in the same way with 4.7.0 2012-01-18 trunk revision 183273.
So marked as NEW.
Created attachment 26443 [details] Draft patch for trans-intrinsic.c There are two issues: a) from_expr->rank *and* to_expr->rank are 0 instead of 1. That's a variant of the issue of PR 51977. b) trans-intrinsic.c's conv_move_alloc does not properly handle polymorphic arrays. For (b) a draft patch is attached. TODO: Regtest it, try combinations of TYPE and CLASS, try CLASS with allocatable components - and CLASS components. To use it, you need to either fix issue (a) or you can try the following hack: --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -2726,0 +2727,5 @@ gfc_check_move_alloc (gfc_expr *from, gfc_expr *to) + /* THIS IS A HACK! */ + if (from->ts.type == BT_CLASS && CLASS_DATA (from)->attr.dimension) + from->rank = CLASS_DATA (from)->as->rank; + if (to->ts.type == BT_CLASS && CLASS_DATA (to)->attr.dimension) + to->rank = CLASS_DATA (to)->as->rank; The patch attached to comment #4 + the "hack" let the test compile without error (although I don't know if it is valid). I have noticed the following changes: For 51948, before the patch I had two errors [macbook] f90/bug% gfc pr51948.f90 pr51948.f90:14.24: call move_alloc (x, func) 1 Error: 'to' argument of 'move_alloc' intrinsic at (1) must be a variable pr51948.f90:7.24: call move_alloc (x, func) 1 Error: the 'from' and 'to' arguments of 'move_alloc' intrinsic at (1) must have the same rank 0/1 After the patch I have only one [macbook] f90/bug% gfc pr51948.f90 pr51948.f90:14.24: call move_alloc (x, func) 1 Error: 'to' argument of 'move_alloc' intrinsic at (1) must be a variable For another avatar and the test in pr51977, the error is replaced by an ICE: before the patch [macbook] f90/bug% gfc pr51948_db_1.f90 pr51948_db_1.f90:7.24: call move_alloc (x, func) 1 Error: the 'from' and 'to' arguments of 'move_alloc' intrinsic at (1) must have the same rank 0/1 after the patch [macbook] f90/bug% gfc pr51948_db_1.f90 pr51948_db_1.f90: In function 'func': pr51948_db_1.f90:9:0: internal compiler error: in fold_convert_loc, at fold-const.c:2016 Author: burnus Date: Fri Jan 27 13:08:52 2012 New Revision: 183622 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183622 Log: 2012-01-27 Tobias Burnus <burnus@net-b.de> PR fortran/51970 PR fortran/51977 * primary.c (gfc_match_varspec. gfc_match_rvalue): Set handle array spec for BT_CLASS. * expr.c (gfc_get_variable_expr, gfc_lval_expr_from_sym) * frontend-passes.c (create_var): Ditto. * resolve.c (resolve_actual_arglist, resolve_assoc_var): Ditto. * trans-decl.c (gfc_trans_deferred_vars): Use class_pointer instead of attr.pointer. (gfc_generate_function_code): Use CLASS_DATA (sym) for BT_CLASS. * trans-intrinsic.c (conv_intrinsic_move_alloc): Move assert. * trans-stmt.c (trans_associate_var): Ask for the descriptor. 2012-01-27 Tobias Burnus <burnus@net-b.de> PR fortran/51970 PR fortran/51977 * gfortran.dg/move_alloc_13.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/move_alloc_13.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/expr.c trunk/gcc/fortran/frontend-passes.c trunk/gcc/fortran/primary.c trunk/gcc/fortran/resolve.c trunk/gcc/fortran/trans-decl.c trunk/gcc/fortran/trans-intrinsic.c trunk/gcc/fortran/trans-stmt.c trunk/gcc/testsuite/ChangeLog FIXED on the trunk (4.7). |