mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-29 06:44:27 +08:00
re PR libfortran/34670 (bounds checking for array intrinsics)
2008-10-21 Thomas Koenig <tkoenig@gcc.gnu.org> PR libfortran/34670 * intrinsics/transpose_generic.c: Implement bounds checking. * m4/transpose.m4: Likewise. * generated/transpose_c8.c: Regenerated. * generated/transpose_c16.c: Regenerated. * generated/transpose_r10.c: Regenerated. * generated/transpose_i8.c: Regenerated. * generated/transpose_c10.c: Regenerated. * generated/transpose_r4.c: Regenerated. * generated/transpose_c4.c: Regenerated. * generated/transpose_i16.c: Regenerated. * generated/transpose_i4.c: Regenerated. * generated/transpose_r8.c: Regenerated. * generated/transpose_r16.c: Regenerated. 2008-10-21 Thomas Koenig <tkoenig@gcc.gnu.org> PR libfortran/34670 * gfortran.dg/transpose_2.f90: New test. From-SVN: r141276
This commit is contained in:
parent
7d40743390
commit
c0c7206d89
@ -1,3 +1,8 @@
|
||||
2008-10-21 Thomas Koenig <tkoenig@gcc.gnu.org>
|
||||
|
||||
PR libfortran/34670
|
||||
* gfortran.dg/transpose_2.f90: New test.
|
||||
|
||||
2008-10-21 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR middle-end/37669
|
||||
|
18
gcc/testsuite/gfortran.dg/transpose_2.f90
Normal file
18
gcc/testsuite/gfortran.dg/transpose_2.f90
Normal file
@ -0,0 +1,18 @@
|
||||
! { dg-do run }
|
||||
! { dg-options "-fbounds-check" }
|
||||
! { dg-shouldfail "Incorrect extent in return value of TRANSPOSE intrinsic in dimension 1: is 2, should be 3" }
|
||||
program main
|
||||
implicit none
|
||||
character(len=10) :: in
|
||||
real, dimension(:,:), allocatable :: a,b
|
||||
integer :: ax, ay, bx, by
|
||||
|
||||
in = "2 2 3 2"
|
||||
read (unit=in,fmt='(4I2)') ax, ay, bx, by
|
||||
allocate (a(ax,ay))
|
||||
allocate (b(bx,by))
|
||||
a = 1.0
|
||||
b = 2.1
|
||||
b = transpose(a)
|
||||
end program main
|
||||
! { dg-output "Fortran runtime error: Incorrect extent in return value of TRANSPOSE intrinsic in dimension 1: is 2, should be 3" }
|
@ -1,3 +1,20 @@
|
||||
2008-10-21 Thomas Koenig <tkoenig@gcc.gnu.org>
|
||||
|
||||
PR libfortran/34670
|
||||
* intrinsics/transpose_generic.c: Implement bounds checking.
|
||||
* m4/transpose.m4: Likewise.
|
||||
* generated/transpose_c8.c: Regenerated.
|
||||
* generated/transpose_c16.c: Regenerated.
|
||||
* generated/transpose_r10.c: Regenerated.
|
||||
* generated/transpose_i8.c: Regenerated.
|
||||
* generated/transpose_c10.c: Regenerated.
|
||||
* generated/transpose_r4.c: Regenerated.
|
||||
* generated/transpose_c4.c: Regenerated.
|
||||
* generated/transpose_i16.c: Regenerated.
|
||||
* generated/transpose_i4.c: Regenerated.
|
||||
* generated/transpose_r8.c: Regenerated.
|
||||
* generated/transpose_r16.c: Regenerated.
|
||||
|
||||
2008-10-19 Jerry DeLisle <jvdelisle@gcc.gnu.org
|
||||
|
||||
PR libfortran/37834
|
||||
|
@ -69,6 +69,28 @@ transpose_c10 (gfc_array_c10 * const restrict ret,
|
||||
|
||||
ret->data = internal_malloc_size (sizeof (GFC_COMPLEX_10) * size0 ((array_t *) ret));
|
||||
ret->offset = 0;
|
||||
} else if (unlikely (compile_options.bounds_check))
|
||||
{
|
||||
index_type ret_extent, src_extent;
|
||||
|
||||
ret_extent = ret->dim[0].ubound + 1 - ret->dim[0].lbound;
|
||||
src_extent = source->dim[1].ubound + 1 - source->dim[1].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 1: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
ret_extent = ret->dim[1].ubound + 1 - ret->dim[1].lbound;
|
||||
src_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 2: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
}
|
||||
|
||||
sxstride = source->dim[0].stride;
|
||||
|
@ -69,6 +69,28 @@ transpose_c16 (gfc_array_c16 * const restrict ret,
|
||||
|
||||
ret->data = internal_malloc_size (sizeof (GFC_COMPLEX_16) * size0 ((array_t *) ret));
|
||||
ret->offset = 0;
|
||||
} else if (unlikely (compile_options.bounds_check))
|
||||
{
|
||||
index_type ret_extent, src_extent;
|
||||
|
||||
ret_extent = ret->dim[0].ubound + 1 - ret->dim[0].lbound;
|
||||
src_extent = source->dim[1].ubound + 1 - source->dim[1].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 1: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
ret_extent = ret->dim[1].ubound + 1 - ret->dim[1].lbound;
|
||||
src_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 2: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
}
|
||||
|
||||
sxstride = source->dim[0].stride;
|
||||
|
@ -69,6 +69,28 @@ transpose_c4 (gfc_array_c4 * const restrict ret,
|
||||
|
||||
ret->data = internal_malloc_size (sizeof (GFC_COMPLEX_4) * size0 ((array_t *) ret));
|
||||
ret->offset = 0;
|
||||
} else if (unlikely (compile_options.bounds_check))
|
||||
{
|
||||
index_type ret_extent, src_extent;
|
||||
|
||||
ret_extent = ret->dim[0].ubound + 1 - ret->dim[0].lbound;
|
||||
src_extent = source->dim[1].ubound + 1 - source->dim[1].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 1: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
ret_extent = ret->dim[1].ubound + 1 - ret->dim[1].lbound;
|
||||
src_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 2: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
}
|
||||
|
||||
sxstride = source->dim[0].stride;
|
||||
|
@ -69,6 +69,28 @@ transpose_c8 (gfc_array_c8 * const restrict ret,
|
||||
|
||||
ret->data = internal_malloc_size (sizeof (GFC_COMPLEX_8) * size0 ((array_t *) ret));
|
||||
ret->offset = 0;
|
||||
} else if (unlikely (compile_options.bounds_check))
|
||||
{
|
||||
index_type ret_extent, src_extent;
|
||||
|
||||
ret_extent = ret->dim[0].ubound + 1 - ret->dim[0].lbound;
|
||||
src_extent = source->dim[1].ubound + 1 - source->dim[1].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 1: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
ret_extent = ret->dim[1].ubound + 1 - ret->dim[1].lbound;
|
||||
src_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 2: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
}
|
||||
|
||||
sxstride = source->dim[0].stride;
|
||||
|
@ -69,6 +69,28 @@ transpose_i16 (gfc_array_i16 * const restrict ret,
|
||||
|
||||
ret->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * size0 ((array_t *) ret));
|
||||
ret->offset = 0;
|
||||
} else if (unlikely (compile_options.bounds_check))
|
||||
{
|
||||
index_type ret_extent, src_extent;
|
||||
|
||||
ret_extent = ret->dim[0].ubound + 1 - ret->dim[0].lbound;
|
||||
src_extent = source->dim[1].ubound + 1 - source->dim[1].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 1: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
ret_extent = ret->dim[1].ubound + 1 - ret->dim[1].lbound;
|
||||
src_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 2: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
}
|
||||
|
||||
sxstride = source->dim[0].stride;
|
||||
|
@ -69,6 +69,28 @@ transpose_i4 (gfc_array_i4 * const restrict ret,
|
||||
|
||||
ret->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * size0 ((array_t *) ret));
|
||||
ret->offset = 0;
|
||||
} else if (unlikely (compile_options.bounds_check))
|
||||
{
|
||||
index_type ret_extent, src_extent;
|
||||
|
||||
ret_extent = ret->dim[0].ubound + 1 - ret->dim[0].lbound;
|
||||
src_extent = source->dim[1].ubound + 1 - source->dim[1].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 1: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
ret_extent = ret->dim[1].ubound + 1 - ret->dim[1].lbound;
|
||||
src_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 2: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
}
|
||||
|
||||
sxstride = source->dim[0].stride;
|
||||
|
@ -69,6 +69,28 @@ transpose_i8 (gfc_array_i8 * const restrict ret,
|
||||
|
||||
ret->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * size0 ((array_t *) ret));
|
||||
ret->offset = 0;
|
||||
} else if (unlikely (compile_options.bounds_check))
|
||||
{
|
||||
index_type ret_extent, src_extent;
|
||||
|
||||
ret_extent = ret->dim[0].ubound + 1 - ret->dim[0].lbound;
|
||||
src_extent = source->dim[1].ubound + 1 - source->dim[1].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 1: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
ret_extent = ret->dim[1].ubound + 1 - ret->dim[1].lbound;
|
||||
src_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 2: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
}
|
||||
|
||||
sxstride = source->dim[0].stride;
|
||||
|
@ -69,6 +69,28 @@ transpose_r10 (gfc_array_r10 * const restrict ret,
|
||||
|
||||
ret->data = internal_malloc_size (sizeof (GFC_REAL_10) * size0 ((array_t *) ret));
|
||||
ret->offset = 0;
|
||||
} else if (unlikely (compile_options.bounds_check))
|
||||
{
|
||||
index_type ret_extent, src_extent;
|
||||
|
||||
ret_extent = ret->dim[0].ubound + 1 - ret->dim[0].lbound;
|
||||
src_extent = source->dim[1].ubound + 1 - source->dim[1].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 1: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
ret_extent = ret->dim[1].ubound + 1 - ret->dim[1].lbound;
|
||||
src_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 2: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
}
|
||||
|
||||
sxstride = source->dim[0].stride;
|
||||
|
@ -69,6 +69,28 @@ transpose_r16 (gfc_array_r16 * const restrict ret,
|
||||
|
||||
ret->data = internal_malloc_size (sizeof (GFC_REAL_16) * size0 ((array_t *) ret));
|
||||
ret->offset = 0;
|
||||
} else if (unlikely (compile_options.bounds_check))
|
||||
{
|
||||
index_type ret_extent, src_extent;
|
||||
|
||||
ret_extent = ret->dim[0].ubound + 1 - ret->dim[0].lbound;
|
||||
src_extent = source->dim[1].ubound + 1 - source->dim[1].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 1: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
ret_extent = ret->dim[1].ubound + 1 - ret->dim[1].lbound;
|
||||
src_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 2: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
}
|
||||
|
||||
sxstride = source->dim[0].stride;
|
||||
|
@ -69,6 +69,28 @@ transpose_r4 (gfc_array_r4 * const restrict ret,
|
||||
|
||||
ret->data = internal_malloc_size (sizeof (GFC_REAL_4) * size0 ((array_t *) ret));
|
||||
ret->offset = 0;
|
||||
} else if (unlikely (compile_options.bounds_check))
|
||||
{
|
||||
index_type ret_extent, src_extent;
|
||||
|
||||
ret_extent = ret->dim[0].ubound + 1 - ret->dim[0].lbound;
|
||||
src_extent = source->dim[1].ubound + 1 - source->dim[1].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 1: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
ret_extent = ret->dim[1].ubound + 1 - ret->dim[1].lbound;
|
||||
src_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 2: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
}
|
||||
|
||||
sxstride = source->dim[0].stride;
|
||||
|
@ -69,6 +69,28 @@ transpose_r8 (gfc_array_r8 * const restrict ret,
|
||||
|
||||
ret->data = internal_malloc_size (sizeof (GFC_REAL_8) * size0 ((array_t *) ret));
|
||||
ret->offset = 0;
|
||||
} else if (unlikely (compile_options.bounds_check))
|
||||
{
|
||||
index_type ret_extent, src_extent;
|
||||
|
||||
ret_extent = ret->dim[0].ubound + 1 - ret->dim[0].lbound;
|
||||
src_extent = source->dim[1].ubound + 1 - source->dim[1].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 1: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
ret_extent = ret->dim[1].ubound + 1 - ret->dim[1].lbound;
|
||||
src_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 2: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
}
|
||||
|
||||
sxstride = source->dim[0].stride;
|
||||
|
@ -68,6 +68,29 @@ transpose_internal (gfc_array_char *ret, gfc_array_char *source,
|
||||
ret->data = internal_malloc_size (size * size0 ((array_t*)ret));
|
||||
ret->offset = 0;
|
||||
}
|
||||
else if (unlikely (compile_options.bounds_check))
|
||||
{
|
||||
index_type ret_extent, src_extent;
|
||||
|
||||
ret_extent = ret->dim[0].ubound + 1 - ret->dim[0].lbound;
|
||||
src_extent = source->dim[1].ubound + 1 - source->dim[1].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 1: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
ret_extent = ret->dim[1].ubound + 1 - ret->dim[1].lbound;
|
||||
src_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 2: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
}
|
||||
|
||||
sxstride = source->dim[0].stride * size;
|
||||
systride = source->dim[1].stride * size;
|
||||
|
@ -70,6 +70,28 @@ transpose_'rtype_code` ('rtype` * const restrict ret,
|
||||
|
||||
ret->data = internal_malloc_size (sizeof ('rtype_name`) * size0 ((array_t *) ret));
|
||||
ret->offset = 0;
|
||||
} else if (unlikely (compile_options.bounds_check))
|
||||
{
|
||||
index_type ret_extent, src_extent;
|
||||
|
||||
ret_extent = ret->dim[0].ubound + 1 - ret->dim[0].lbound;
|
||||
src_extent = source->dim[1].ubound + 1 - source->dim[1].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 1: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
ret_extent = ret->dim[1].ubound + 1 - ret->dim[1].lbound;
|
||||
src_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
|
||||
|
||||
if (src_extent != ret_extent)
|
||||
runtime_error ("Incorrect extent in return value of TRANSPOSE"
|
||||
" intrinsic in dimension 2: is %ld,"
|
||||
" should be %ld", (long int) src_extent,
|
||||
(long int) ret_extent);
|
||||
|
||||
}
|
||||
|
||||
sxstride = source->dim[0].stride;
|
||||
|
Loading…
Reference in New Issue
Block a user