[gfortran] Fix PR 24643
Tobias Schlüter
tobias.schlueter@physik.uni-muenchen.de
Tue Nov 8 23:57:00 GMT 2005
PR 24643 is a case where we rejected vallid code because we wouldn't accept a
substring of a aymbol with FL_VARIABLE but BT_UNKNOWN, in other words
substrings of implicitly typed character variables wouldn't work if the
variable had been used before. This patch makes sure that we give them the
right type before looking for the substring specifier.
While testing this, I ran into a preexisting ice-on-invalid-code bug which I
opened PR 24748 for.
Bubblestrapped and tested, two new testcases attached. Ok?
- Tobi
2005-11-09 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/24643
* primary.c (match_varspec): Check for implicitly typed CHARACTER
variables before matching substrings.
testsuite:
* gfortran.dg/implicit_6.f90, gfortran.dg/implicit_7.f90: New.
Index: fortran/primary.c
===================================================================
--- fortran/primary.c (revision 106651)
+++ fortran/primary.c (working copy)
@@ -1634,6 +1634,15 @@ match_varspec (gfc_expr * primary, int e
}
check_substring:
+ if (primary->ts.type == BT_UNKNOWN)
+ {
+ if (gfc_get_default_type (sym, sym->ns)->type == BT_CHARACTER)
+ {
+ gfc_set_default_type (sym, 0, sym->ns);
+ primary->ts = sym->ts;
+ }
+ }
+
if (primary->ts.type == BT_CHARACTER)
{
switch (match_substring (primary->ts.cl, equiv_flag, &substring))
Index: testsuite/gfortran.dg/implicit_6.f90
===================================================================
--- testsuite/gfortran.dg/implicit_6.f90 (revision 0)
+++ testsuite/gfortran.dg/implicit_6.f90 (revision 0)
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR 24643
+! substring references on implicitly typed CHARACTER variables didn't work
+ PROGRAM P
+ IMPLICIT CHARACTER*8 (Y)
+ YLOCAL='A'
+ YBTABLE=YLOCAL(1:2)
+ END
Index: testsuite/gfortran.dg/implicit_7.f90
===================================================================
--- testsuite/gfortran.dg/implicit_7.f90 (revision 0)
+++ testsuite/gfortran.dg/implicit_7.f90 (revision 0)
@@ -0,0 +1,7 @@
+! { dg-do compile }
+! PR 24643
+! This tests a case where the compiler used to ICE in an early
+! incarnation of the patch
+ylocal=1
+ybtable=ylocal(1:2) ! { dg-error "Unclassifiable" }
+end
More information about the Fortran
mailing list