It crashes in match.c's gfc_match_select_type: class_array = expr1->expr_type == EXPR_VARIABLE && expr1->ts.type != BT_UNKNOWN && CLASS_DATA (expr1) ... as for obvious reasons, a non-BT_CLASS doesn't have CLASS_DATA. Test case, reported by xarthisius on #gfortran: subroutine foo(x) ! type(*) :: x integer :: x select type (x) end select type end
As postscript: Non BT_CLASS should be directly rejected. From F2008: C837 (R847) The selector in a select-type-stmt shall be polymorphic.
*** Bug 54434 has been marked as a duplicate of this bug. ***
I marked it as regression as with 4.6 it doesn't ICE ("class_array =" is new in 4.7). Though, the error message of 4.6 is not really that helpful: end select type 1 Error: Syntax error in END SELECT statement at (1)
(In reply to comment #1) > As postscript: Non BT_CLASS should be directly rejected. From F2008: > > C837 (R847) The selector in a select-type-stmt shall be polymorphic. We have such a check in resolve_select_type, which obviously comes too late for gfc_match_select_type.
This kills the ICE and gets us back at least to the 4.6 behavior (see comment #3): Index: gcc/fortran/match.c =================================================================== --- gcc/fortran/match.c (revision 190419) +++ gcc/fortran/match.c (working copy) @@ -5367,10 +5367,10 @@ gfc_match_select_type (void) array, which can have a reference, from other expressions that have references, such as derived type components, and are not allowed by the standard. - TODO; see is it is sufficient to exclude component and substring + TODO: see if it is sufficient to exclude component and substring references. */ class_array = expr1->expr_type == EXPR_VARIABLE - && expr1->ts.type != BT_UNKNOWN + && expr1->ts.type == BT_CLASS && CLASS_DATA (expr1) && (strcmp (CLASS_DATA (expr1)->name, "_data") == 0) && (CLASS_DATA (expr1)->attr.dimension
(In reply to comment #3) > Though, the error message of 4.6 is not really that helpful: > > end select type > 1 > Error: Syntax error in END SELECT statement at (1) Well, it's helpful in that it spots a syntax error in the test case: The correct form is END SELECT. If ones fixes the test case in this respect ... subroutine foo(x) integer :: x select type (x) end select end ... then it is rejected by the patch in comment 5 with the correct error message: select type (x) 1 Error: Selector shall be polymorphic in SELECT TYPE statement at (1) I'll start a regtest of the the patch now ...
(In reply to comment #6) > I'll start a regtest of the the patch now ... Apparently there have been some (middle-end?) issues on the trunk lately, causing a good number of testsuite failures. However, at r190845, the patch in comment 5 regtests cleanly. I will commit to trunk as obvious soon. What about 4.7?
Author: janus Date: Tue Sep 4 08:03:09 2012 New Revision: 190910 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190910 Log: 2012-09-04 Janus Weil <janus@gcc.gnu.org> PR fortran/54435 PR fortran/54443 * match.c (gfc_match_select_type): Make sure to only access CLASS_DATA for BT_CLASS. 2012-09-04 Janus Weil <janus@gcc.gnu.org> PR fortran/54243 PR fortran/54244 * gfortran.dg/select_type_29.f03: New. Added: trunk/gcc/testsuite/gfortran.dg/select_type_29.f03 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/match.c trunk/gcc/testsuite/ChangeLog
Author: janus Date: Mon Sep 10 12:10:12 2012 New Revision: 191135 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=191135 Log: 2012-09-10 Janus Weil <janus@gcc.gnu.org> PR fortran/54435 PR fortran/54443 * match.c (gfc_match_select_type): Make sure to only access CLASS_DATA for BT_CLASS. 2012-09-10 Janus Weil <janus@gcc.gnu.org> PR fortran/54435 PR fortran/54443 * gfortran.dg/select_type_29.f03: New. Added: branches/gcc-4_7-branch/gcc/testsuite/gfortran.dg/select_type_29.f03 Modified: branches/gcc-4_7-branch/gcc/fortran/ChangeLog branches/gcc-4_7-branch/gcc/fortran/match.c branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
Fixed on trunk and 4.7. Closing.
Dear Janus, Thanks for dealing with that. Cheers Paul On 10 September 2012 14:14, janus at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org> wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54435 > > janus at gcc dot gnu.org changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > Status|ASSIGNED |RESOLVED > Resolution| |FIXED > > --- Comment #10 from janus at gcc dot gnu.org 2012-09-10 12:14:00 UTC --- > Fixed on trunk and 4.7. Closing. > > -- > Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email > ------- You are receiving this mail because: ------- > You are on the CC list for the bug.