Summary: | ICE in gfc_element_size, at fortran/target-memory.c:126 | ||
---|---|---|---|
Product: | gcc | Reporter: | G. Steinmetz <gscfq> |
Component: | fortran | Assignee: | anlauf |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | anlauf |
Priority: | P4 | Keywords: | ice-on-invalid-code |
Version: | 9.0 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2018-05-16 00:00:00 |
Description
G. Steinmetz
2018-05-15 19:16:15 UTC
Confirmed. The following patch generates errors for the testcases when one of the TRANSFER arguments is a procedure (but not a pointer): Index: gcc/fortran/check.c =================================================================== --- gcc/fortran/check.c (revision 269717) +++ gcc/fortran/check.c (working copy) @@ -5551,6 +5551,24 @@ return false; } + if (source->ts.type == BT_PROCEDURE + && !source->symtree->n.sym->attr.pointer) + { + gfc_error ("%<SOURCE%> argument of %<TRANSFER%> intrinsic at %L " + "must not be a %s", &source->where, + gfc_basic_typename (source->ts.type)); + return false; + } + + if (mold->ts.type == BT_PROCEDURE + && !mold->symtree->n.sym->attr.pointer) + { + gfc_error ("%<MOLD%> argument of %<TRANSFER%> intrinsic at %L " + "must not be a %s", &mold->where, + gfc_basic_typename (mold->ts.type)); + return false; + } + if (size != NULL) { if (!type_check (size, 2, BT_INTEGER)) Needs regtesting. Patch submitted: https://gcc.gnu.org/ml/fortran/2019-03/msg00099.html Revised patch that also addresses PR83515: https://gcc.gnu.org/ml/fortran/2019-03/msg00109.html > Revised patch that also addresses PR83515:
The patch fixes the ICE. Compiling the tests z2.f90 or z3.f90 gives the error
2 | c = transfer(a, a)
| 1
Error: Cannot convert PROCEDURE to REAL(4) at (1)
or
2 | c = transfer(b, a)
| 1
Error: Cannot convert PROCEDURE to REAL(4) at (1)
Author: anlauf Date: Sun Mar 31 18:33:51 2019 New Revision: 270045 URL: https://gcc.gnu.org/viewcvs?rev=270045&root=gcc&view=rev Log: 2019-03-31 Harald Anlauf <anlauf@gmx.de> PR fortran/83515 PR fortran/85797 * trans-types.c (gfc_typenode_for_spec): Handle conversion for procedure pointers. * target-memory.c (gfc_element_size): Handle size determination for procedure pointers. PR fortran/83515 PR fortran/85797 * gfortran.dg/pr85797.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/pr85797.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/target-memory.c trunk/gcc/fortran/trans-types.c trunk/gcc/testsuite/ChangeLog Author: anlauf Date: Sun Mar 31 19:08:23 2019 New Revision: 270046 URL: https://gcc.gnu.org/viewcvs?rev=270046&root=gcc&view=rev Log: 2019-03-31 Harald Anlauf <anlauf@gmx.de> PR fortran/83515 PR fortran/85797 * trans-types.c (gfc_typenode_for_spec): Handle conversion for procedure pointers. * target-memory.c (gfc_element_size): Handle size determination for procedure pointers. PR fortran/83515 PR fortran/85797 * gfortran.dg/pr85797.f90: New test. Added: branches/gcc-8-branch/gcc/testsuite/gfortran.dg/pr85797.f90 Modified: branches/gcc-8-branch/gcc/fortran/ChangeLog branches/gcc-8-branch/gcc/fortran/target-memory.c branches/gcc-8-branch/gcc/fortran/trans-types.c branches/gcc-8-branch/gcc/testsuite/ChangeLog Author: anlauf Date: Sun Mar 31 19:21:37 2019 New Revision: 270047 URL: https://gcc.gnu.org/viewcvs?rev=270047&root=gcc&view=rev Log: 2019-03-31 Harald Anlauf <anlauf@gmx.de> Backport from trunk PR fortran/83515 PR fortran/85797 * trans-types.c (gfc_typenode_for_spec): Handle conversion for procedure pointers. * target-memory.c (gfc_element_size): Handle size determination for procedure pointers. PR fortran/83515 PR fortran/85797 * gfortran.dg/pr85797.f90: New test. Added: branches/gcc-7-branch/gcc/testsuite/gfortran.dg/pr85797.f90 Modified: branches/gcc-7-branch/gcc/fortran/ChangeLog branches/gcc-7-branch/gcc/fortran/target-memory.c branches/gcc-7-branch/gcc/fortran/trans-types.c branches/gcc-7-branch/gcc/testsuite/ChangeLog Fixed on trunk and open branches (7/8). Thanks for the report! |