Summary: | [4.7 Regression] [OOP] gfc_variable_attr(): Bad array reference in SELECT TYPE | ||
---|---|---|---|
Product: | gcc | Reporter: | Andrew Benson <abensonca> |
Component: | fortran | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | jakub, janus, pault |
Priority: | P4 | Keywords: | ice-on-invalid-code |
Version: | 4.7.3 | ||
Target Milestone: | 4.7.4 | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2012-11-02 00:00:00 |
Description
Andrew Benson
2012-11-01 22:42:17 UTC
(In reply to comment #0) > (Reported by Janus at http://gcc.gnu.org/ml/fortran/2012-11/msg00005.html): > With 4.7 the ICE also occurs, but only after the correct error message: > > select type (component => self%cb(i)) > 1 > Error: Symbol 'i' at (1) has no IMPLICIT type Yes, therefore it's a regression in 4.7 (ICE after error) and 4.8 (ICE only). 4.6 of course rejects it ('cleanly') with: class(ncb), allocatable, dimension(:) :: cb 1 Fatal Error: Polymorphic array at (1) not yet supported (Side note: The 'fatal' seems a bit strong here, but that was probably used to suppress further error messages.) I suspect the 4.8-problem of having only the ICE without a prior error message might be due to this commit: http://gcc.gnu.org/viewcvs?view=revision&revision=187192 I think the function 'copy_ts_from_selector_to_associate' comes too early (namely during parsing). It tries to resolve the target expr, which should rather wait until resolution stage!?! (In reply to comment #2) > I suspect the 4.8-problem of having only the ICE without a prior error message > might be due to this commit: > > http://gcc.gnu.org/viewcvs?view=revision&revision=187192 > > I think the function 'copy_ts_from_selector_to_associate' comes too early > (namely during parsing). It tries to resolve the target expr, which should > rather wait until resolution stage!?! This is partially correct. Unfortunately, the selector expression comes from the parser with the ar->type == AR_UNKNOWN and it was this that gfc_resolve_expr was putting right. As long as all the variables were declared or had implicit types, all was well. Th is fixed by removing the call to gfc_resolve_expr and adding explicit code, copied from resolve_array_ref, to set the correct type. It is also necessary/advisable to add a call to resolve the selector expression in resolve_select_type. I will submit a patch later today. Cheers Paul PS If the index 'i' is declared, wrong code results as in pr54990. Author: pault Date: Fri Jan 4 20:50:15 2013 New Revision: 194916 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194916 Log: 2013-01-04 Paul Thomas <pault@gcc.gnu.org> PR fortran/55172 * match.c (copy_ts_from_selector_to_associate): Remove call to gfc_resolve_expr and replace it with explicit setting of the array reference type. * resolve.c (resolve_select_type): It is an error if the selector is coindexed. 2013-01-04 Paul Thomas <pault@gcc.gnu.org> PR fortran/55172 * gfortran.dg/select_type_31.f03: New test. Added: trunk/gcc/testsuite/gfortran.dg/select_type_31.f03 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/match.c trunk/gcc/fortran/resolve.c trunk/gcc/testsuite/ChangeLog I tried the best I could with 4.7 but there are quite significant divergences with trunk, both around and downstream from the patch. The best that I could manage was: /svn/gcc-4_7-branch/gcc/testsuite/gfortran.dg/select_type_31.f03:16.4: select type (component => self%cb(i) ! { dg-error "has no IMPLICIT type" } 1 Error: Unclassifiable statement at (1) /svn/gcc-4_7-branch/gcc/testsuite/gfortran.dg/select_type_31.f03:17.7: end select 1 Error: Expecting END FUNCTION statement at (1) which is more opaque than the correct error followed by the internal error! I decided, therefore, to leave the PR as 4.7 only and have unassigned myself. In addition, I think that to call it a regression is incorrect since polymorphic arrays were unavailable in 4.6! I have therefore removed regression from the title. I might be persuaded to return to this, once 4.8 is released. Paul GCC 4.7.3 is being released, adjusting target milestone. I think that it is best to leave this unfixed for 4.7 - see comment #5 I have therefore marked the PR as resolved. Thanks for the report Paul |