summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2009-10-24 10:11:46 +0000
committerPaul Thomas <pault@gcc.gnu.org>2009-10-24 10:11:46 +0000
commitc0f81f78ae9aa3931b3b5472eb138ff3815d10de (patch)
treef452f5f60bd73aae0cda761c395451b394c5a89d /gcc
parent72580319c22c1b44c6c6284a65ef021a20d7b8c2 (diff)
downloadgcc-c0f81f78ae9aa3931b3b5472eb138ff3815d10de.tar.gz
re PR fortran/41772 (Wrong code due to TRANSFER of EMPTY array section)
2009-10-24 Paul Thomas <pault@gcc.gnu.org> PR fortran/41772 * trans-intrinsic.c (gfc_conv_intrinsic_transfer): Stop'extent' from going negative. 2009-10-24 Paul Thomas <pault@gcc.gnu.org> PR fortran/41772 * gfortran.dg/transfer_intrinsic_3.f90. From-SVN: r153524
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/trans-intrinsic.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/transfer_intrinsic_3.f9038
4 files changed, 51 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index bc4ecb03d3e..cf6c8cd2dcb 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2009-10-24 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/41772
+ * trans-intrinsic.c (gfc_conv_intrinsic_transfer): Stop'extent'
+ from going negative.
+
2009-10-23 Janus Weil <janus@gcc.gnu.org>
PR fortran/41800
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index 1e7b35f5c17..c3d7dfbab3c 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -4490,6 +4490,8 @@ gfc_conv_intrinsic_transfer (gfc_se * se, gfc_expr * expr)
scalar_transfer:
extent = fold_build2 (MIN_EXPR, gfc_array_index_type,
dest_word_len, source_bytes);
+ extent = fold_build2 (MAX_EXPR, gfc_array_index_type,
+ extent, gfc_index_zero_node);
if (expr->ts.type == BT_CHARACTER)
{
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 481a82e6c78..676b5a73a55 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2009-10-24 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/41772
+ * gfortran.dg/transfer_intrinsic_3.f90.
+
2009-10-24 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/opt4.adb: New test.
diff --git a/gcc/testsuite/gfortran.dg/transfer_intrinsic_3.f90 b/gcc/testsuite/gfortran.dg/transfer_intrinsic_3.f90
new file mode 100644
index 00000000000..f0b9b546877
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/transfer_intrinsic_3.f90
@@ -0,0 +1,38 @@
+! { dg-do run }
+! Tests the fix for PR41772 in which the empty array reference
+! 'qname(1:n-1)' was not handled correctly in TRANSFER.
+!
+! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
+!
+module m
+ implicit none
+contains
+ pure function str_vs(vs) result(s)
+ character, dimension(:), intent(in) :: vs
+ character(len=size(vs)) :: s
+ s = transfer(vs, s)
+ end function str_vs
+ subroutine has_key_ns(uri, localname, n)
+ character(len=*), intent(in) :: uri, localname
+ integer, intent(in) :: n
+ if ((n .lt. 2) .and. (len (uri) .ne. 0)) then
+ call abort
+ else IF ((n .ge. 2) .and. (len (uri) .ne. n - 1)) then
+ call abort
+ end if
+ end subroutine
+end module m
+
+ use m
+ implicit none
+ character, dimension(:), pointer :: QName
+ integer :: n
+ allocate(qname(6))
+ qname = (/ 'a','b','c','d','e','f' /)
+
+ do n = 0, 3
+ call has_key_ns(str_vs(qname(1:n-1)),"", n)
+ end do
+ deallocate(qname)
+end
+! { dg-final { cleanup-modules "m" } } \ No newline at end of file