From: Steven G. Kargl Date: Wed, 4 Sep 2019 23:21:12 +0000 (+0000) Subject: re PR fortran/91650 (ICE in gfc_conv_constant_to_tree, at fortran/trans-const.c:370) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4844a5cb8c37e84eb742471a52dc927ac5cdd16d;p=gcc.git re PR fortran/91650 (ICE in gfc_conv_constant_to_tree, at fortran/trans-const.c:370) 2019-09-04 Steven G. Kargl PR fortran/91650 * io.c (match_io_element): An output IO list item cannot be a BOZ. 2019-09-04 Steven G. Kargl PR fortran/91650 * gfortran.dg/pr91650_1.f90: New test. * gfortran.dg/pr91650_2.f90: Ditto. From-SVN: r275391 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b866cdf3b98..4da49108c9d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2019-09-04 Steven G. Kargl + + PR fortran/91650 + * io.c (match_io_element): An output IO list item cannot be a BOZ. + 2019-09-03 Steven G. Kargl * gfortran.texi: Update documentation to catch up with BOZ changes. diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index 632e168809d..d57b7471da2 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -3675,6 +3675,15 @@ match_io_element (io_kind k, gfc_code **cpp) if (m == MATCH_NO) gfc_error ("Expected expression in %s statement at %C", io_kind_name (k)); + + if (m == MATCH_YES && expr->ts.type == BT_BOZ) + { + if (gfc_invalid_boz ("BOZ literal constant at %L cannot appear in " + "an output IO list", &gfc_current_locus)) + return MATCH_ERROR; + if (!gfc_boz2int (expr, gfc_max_integer_kind)) + return MATCH_ERROR; + }; } if (m == MATCH_YES && k == M_READ && gfc_check_do_variable (expr->symtree)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ecde4ca1c93..11d6fab7044 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-09-04 Steven G. Kargl + + PR fortran/91650 + * gfortran.dg/pr91650_1.f90: New test. + * gfortran.dg/pr91650_2.f90: Ditto. + 2019-09-04 Marek Polacek * g++.dg/cpp0x/initlist-deduce.C: Don't use -fdeduce-init-list. Remove diff --git a/gcc/testsuite/gfortran.dg/pr91650_1.f90 b/gcc/testsuite/gfortran.dg/pr91650_1.f90 new file mode 100644 index 00000000000..1cda096c422 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr91650_1.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR fortran/91650 +! Code contributed by Gerhard Steinmetz. +program p + print *, b'10110' ! { dg-error "cannot appear in an output IO list" } + print *, o'10110' ! { dg-error "cannot appear in an output IO list" } + print *, z'10110' ! { dg-error "cannot appear in an output IO list" } +end diff --git a/gcc/testsuite/gfortran.dg/pr91650_2.f90 b/gcc/testsuite/gfortran.dg/pr91650_2.f90 new file mode 100644 index 00000000000..28316ec1de5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr91650_2.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! { dg-options "-fallow-invalid-boz" } +! PR fortran/91650 +! Code contributed by Gerhard Steinmetz. +program p + character(len=60) str + write(str,*) b'10110' ! { dg-warning "cannot appear in an output IO list" } + if (trim(adjustl(str)) /= '22') stop 1 + write(str,*) o'10110' ! { dg-warning "cannot appear in an output IO list" } + if (trim(adjustl(str)) /= '4168') stop 2 + write(str,*) z'10110' ! { dg-warning "cannot appear in an output IO list" } + if (trim(adjustl(str)) /= '65808') stop 3 +end