Commit 2c4f9ec1 by Tobias Burnus Committed by Tobias Burnus

revert: re PR fortran/83522 (ICE on allocatable string reference, string(:)(:))

2018-10-11  Tobias Burnus <burnus@net-b.de>

        Revert:
        2018-10-09  Tobias Burnus <burnus@net-b.de>

        PR fortran/83522
        * resolve.c (resolve_ref): Reject nonscalar
        substring references.

2018-10-11  Tobias Burnus <burnus@net-b.de>

        Revert:
        2018-10-09  Tobias Burnus <burnus@net-b.de>

        PR fortran/83522
        * gfortran.dg/actual_array_substr_1.f90: Add dg-error,
        change to dg-do compile.
        * gfortran.dg/actual_array_substr_2.f90: Ditto.
        * gfortran.dg/array_initializer_1.f90: Use array
        element not size-one section.
        * gfortran.dg/array_substring.f90: New.

From-SVN: r265059
parent 1b6acf23
2018-10-11 Tobias Burnus <burnus@net-b.de>
Revert:
2018-10-09 Tobias Burnus <burnus@net-b.de>
PR fortran/83522
* resolve.c (resolve_ref): Reject nonscalar
substring references.
2018-10-09 David Malcolm <dmalcolm@redhat.com> 2018-10-09 David Malcolm <dmalcolm@redhat.com>
* cpp.c (gfc_cpp_init_0): Update for renamings. * cpp.c (gfc_cpp_init_0): Update for renamings.
......
...@@ -5129,13 +5129,6 @@ resolve_ref (gfc_expr *expr) ...@@ -5129,13 +5129,6 @@ resolve_ref (gfc_expr *expr)
break; break;
case REF_SUBSTRING: case REF_SUBSTRING:
/* F2008, R610 alias F2018, R908. */
if (current_part_dimension || seen_part_dimension)
{
gfc_error ("Substring reference of nonscalar not permitted at %L",
&expr->where);
return false;
}
break; break;
} }
......
2018-10-11 Tobias Burnus <burnus@net-b.de>
Revert:
2018-10-09 Tobias Burnus <burnus@net-b.de>
PR fortran/83522
* gfortran.dg/actual_array_substr_1.f90: Add dg-error,
change to dg-do compile.
* gfortran.dg/actual_array_substr_2.f90: Ditto.
* gfortran.dg/array_initializer_1.f90: Use array
element not size-one section.
* gfortran.dg/array_substring.f90: New.
2018-10-11 Wilco Dijkstra <wdijkstr@arm.com> 2018-10-11 Wilco Dijkstra <wdijkstr@arm.com>
PR target/87511 PR target/87511
......
! { dg-do compile } ! { dg-do run }
! Test fix of PR28118, in which a substring reference to an ! Test fix of PR28118, in which a substring reference to an
! actual argument with an array reference would cause a segfault. ! actual argument with an array reference would cause a segfault.
! !
! Revised for PR fortran/83522
!
! Contributed by Paul Thomas <pault@gcc.gnu.org> ! Contributed by Paul Thomas <pault@gcc.gnu.org>
! !
program gfcbug33 program gfcbug33
character(12) :: a(2) character(12) :: a(2)
a(1) = "abcdefghijkl" a(1) = "abcdefghijkl"
a(2) = "mnopqrstuvwx" a(2) = "mnopqrstuvwx"
call foo ((a(2:1:-1)(6:))) ! { dg-error "Substring reference of nonscalar not permitted" } call foo ((a(2:1:-1)(6:)))
call bar ((a(:)(7:11))) ! { dg-error "Substring reference of nonscalar not permitted" } call bar ((a(:)(7:11)))
contains contains
subroutine foo (chr) subroutine foo (chr)
character(7) :: chr(:) character(7) :: chr(:)
......
! { dg-do compile } ! { dg-do run }
! Tests the fix for pr28174, in which the fix for pr28118 was ! Tests the fix for pr28174, in which the fix for pr28118 was
! corrupting the character lengths of arrays that shared a ! corrupting the character lengths of arrays that shared a
! character length structure. In addition, in developing the ! character length structure. In addition, in developing the
! fix, it was noted that intent(out/inout) arguments were not ! fix, it was noted that intent(out/inout) arguments were not
! getting written back to the calling scope. ! getting written back to the calling scope.
! !
! Revised for PR fortran/83522
!
! Based on the testscase by Harald Anlauf <anlauf@gmx.de> ! Based on the testscase by Harald Anlauf <anlauf@gmx.de>
! !
program pr28174 program pr28174
...@@ -22,7 +20,7 @@ program pr28174 ...@@ -22,7 +20,7 @@ program pr28174
n = m - 4 n = m - 4
! Make sure that variable substring references work. ! Make sure that variable substring references work.
call foo (a(:)(m:m+5), c(:)(n:m+2), d(:)(5:9)) ! { dg-error "Substring reference of nonscalar not permitted" } call foo (a(:)(m:m+5), c(:)(n:m+2), d(:)(5:9))
if (any (a .ne. teststring)) STOP 1 if (any (a .ne. teststring)) STOP 1
if (any (b .ne. teststring)) STOP 2 if (any (b .ne. teststring)) STOP 2
if (any (c .ne. (/"ab456789#hij", & if (any (c .ne. (/"ab456789#hij", &
...@@ -39,7 +37,8 @@ contains ...@@ -39,7 +37,8 @@ contains
! This next is not required by the standard but tests the ! This next is not required by the standard but tests the
! functioning of the gfortran implementation. ! functioning of the gfortran implementation.
! if (all (x(:)(3:7) .eq. y)) STOP 5 ! if (all (x(:)(3:7) .eq. y)) STOP 5
x = foostring (:)(5 : 4 + len (x)) ! { dg-error "Substring reference of nonscalar not permitted" } x = foostring (:)(5 : 4 + len (x))
y = foostring (:)(3 : 2 + len (y)) ! { dg-error "Substring reference of nonscalar not permitted" } y = foostring (:)(3 : 2 + len (y))
end subroutine foo end subroutine foo
end program pr28174 end program pr28174
! { dg-do compile }
!
! PR fortran/83522
!
! Contributed by urbanjost and Jerry DeLisle
!
program testit
character(len=:),allocatable :: strings(:)
integer :: i
strings=[character(len=2) :: 'AA','BB']
write(*,*)strings(:)(:) ! { dg-error "Substring reference of nonscalar not permitted" }
!strings(:)(:) ! Parse error: "Invalid character in name"
strings(:)(:) = 'x' ! { dg-error "Substring reference of nonscalar not permitted" }
do i=1, size(strings)
write(*,*)strings(i)(:) ! This is valid and works
end do
end program testit
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment