+2008-11-18 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR libfortran/38135
+ * gfortran.dg/reshape_pad_1.f90: New test case.
+
2008-11-18 Uros Bizjak <ubizjak@gmail.com>
PR target/37362
--- /dev/null
+! { dg-do run }
+! PR 38135 - pad to RESHAPE didn't work correctly when SOURCE
+! was an empty array.
+
+program main
+ implicit none
+ integer, parameter :: N = 3
+ integer(kind=1) :: A1(N,N)
+ integer(kind=1) :: b1(n+1)
+ integer(kind=4) :: A4(n,n)
+ integer(kind=4) :: b4(n+1)
+ character(len=9) :: line
+
+ b1 = (/ 1, 2, 2, 2 /)
+
+ A1(1:N,1:N)=reshape(A1(1:0,1),(/N,N/),b1)
+ write(unit=line,fmt='(100i1)') A1
+ if (line .ne. "122212221") call abort
+
+ b4 = (/ 3, 4, 4, 4 /)
+
+ a4 = reshape(a4(:0,1),(/n,n/),b4)
+ write(unit=line,fmt='(100i1)') a4
+ if (line .ne. "344434443") call abort
+end program main
+2008-11-18 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR libfortran/38135
+ * m4/reshape.m4: Correct bounds checking when PAD is present.
+ Treat PAD as if it were SOURCE when SOURCE is empty.
+ * intrinsics/reshape_generic.c: Likewise.
+ * generated/reshape_c10.c Regenerated.
+ * generated/reshape_c16.c Regenerated.
+ * generated/reshape_c4.c Regenerated.
+ * generated/reshape_c8.c Regenerated.
+ * generated/reshape_i16.c Regenerated.
+ * generated/reshape_i4.c Regenerated.
+ * generated/reshape_i8.c Regenerated.
+ * generated/reshape_r10.c Regenerated.
+ * generated/reshape_r16.c Regenerated.
+ * generated/reshape_r4.c Regenerated.
+ * generated/reshape_r8.c Regenerated.
+
2008-11-16 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/38097
source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
- if (rs != source_extent)
+ if (rs < source_extent || (rs > source_extent && !pad))
runtime_error("Incorrect size in SOURCE argument to RESHAPE"
" intrinsic: is %ld, should be %ld",
(long int) source_extent, (long int) rs);
if (sempty)
{
- /* Switch immediately to the pad array. */
+ /* Pretend we are using the pad array the first time around, too. */
src = pptr;
- sptr = NULL;
+ sptr = pptr;
sdim = pdim;
for (dim = 0; dim < pdim; dim++)
{
scount[dim] = pcount[dim];
sextent[dim] = pextent[dim];
sstride[dim] = pstride[dim];
- sstride0 = sstride[0] * sizeof (GFC_COMPLEX_10);
+ sstride0 = pstride[0];
}
}
source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
- if (rs != source_extent)
+ if (rs < source_extent || (rs > source_extent && !pad))
runtime_error("Incorrect size in SOURCE argument to RESHAPE"
" intrinsic: is %ld, should be %ld",
(long int) source_extent, (long int) rs);
if (sempty)
{
- /* Switch immediately to the pad array. */
+ /* Pretend we are using the pad array the first time around, too. */
src = pptr;
- sptr = NULL;
+ sptr = pptr;
sdim = pdim;
for (dim = 0; dim < pdim; dim++)
{
scount[dim] = pcount[dim];
sextent[dim] = pextent[dim];
sstride[dim] = pstride[dim];
- sstride0 = sstride[0] * sizeof (GFC_COMPLEX_16);
+ sstride0 = pstride[0];
}
}
source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
- if (rs != source_extent)
+ if (rs < source_extent || (rs > source_extent && !pad))
runtime_error("Incorrect size in SOURCE argument to RESHAPE"
" intrinsic: is %ld, should be %ld",
(long int) source_extent, (long int) rs);
if (sempty)
{
- /* Switch immediately to the pad array. */
+ /* Pretend we are using the pad array the first time around, too. */
src = pptr;
- sptr = NULL;
+ sptr = pptr;
sdim = pdim;
for (dim = 0; dim < pdim; dim++)
{
scount[dim] = pcount[dim];
sextent[dim] = pextent[dim];
sstride[dim] = pstride[dim];
- sstride0 = sstride[0] * sizeof (GFC_COMPLEX_4);
+ sstride0 = pstride[0];
}
}
source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
- if (rs != source_extent)
+ if (rs < source_extent || (rs > source_extent && !pad))
runtime_error("Incorrect size in SOURCE argument to RESHAPE"
" intrinsic: is %ld, should be %ld",
(long int) source_extent, (long int) rs);
if (sempty)
{
- /* Switch immediately to the pad array. */
+ /* Pretend we are using the pad array the first time around, too. */
src = pptr;
- sptr = NULL;
+ sptr = pptr;
sdim = pdim;
for (dim = 0; dim < pdim; dim++)
{
scount[dim] = pcount[dim];
sextent[dim] = pextent[dim];
sstride[dim] = pstride[dim];
- sstride0 = sstride[0] * sizeof (GFC_COMPLEX_8);
+ sstride0 = pstride[0];
}
}
source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
- if (rs != source_extent)
+ if (rs < source_extent || (rs > source_extent && !pad))
runtime_error("Incorrect size in SOURCE argument to RESHAPE"
" intrinsic: is %ld, should be %ld",
(long int) source_extent, (long int) rs);
if (sempty)
{
- /* Switch immediately to the pad array. */
+ /* Pretend we are using the pad array the first time around, too. */
src = pptr;
- sptr = NULL;
+ sptr = pptr;
sdim = pdim;
for (dim = 0; dim < pdim; dim++)
{
scount[dim] = pcount[dim];
sextent[dim] = pextent[dim];
sstride[dim] = pstride[dim];
- sstride0 = sstride[0] * sizeof (GFC_INTEGER_16);
+ sstride0 = pstride[0];
}
}
source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
- if (rs != source_extent)
+ if (rs < source_extent || (rs > source_extent && !pad))
runtime_error("Incorrect size in SOURCE argument to RESHAPE"
" intrinsic: is %ld, should be %ld",
(long int) source_extent, (long int) rs);
if (sempty)
{
- /* Switch immediately to the pad array. */
+ /* Pretend we are using the pad array the first time around, too. */
src = pptr;
- sptr = NULL;
+ sptr = pptr;
sdim = pdim;
for (dim = 0; dim < pdim; dim++)
{
scount[dim] = pcount[dim];
sextent[dim] = pextent[dim];
sstride[dim] = pstride[dim];
- sstride0 = sstride[0] * sizeof (GFC_INTEGER_4);
+ sstride0 = pstride[0];
}
}
source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
- if (rs != source_extent)
+ if (rs < source_extent || (rs > source_extent && !pad))
runtime_error("Incorrect size in SOURCE argument to RESHAPE"
" intrinsic: is %ld, should be %ld",
(long int) source_extent, (long int) rs);
if (sempty)
{
- /* Switch immediately to the pad array. */
+ /* Pretend we are using the pad array the first time around, too. */
src = pptr;
- sptr = NULL;
+ sptr = pptr;
sdim = pdim;
for (dim = 0; dim < pdim; dim++)
{
scount[dim] = pcount[dim];
sextent[dim] = pextent[dim];
sstride[dim] = pstride[dim];
- sstride0 = sstride[0] * sizeof (GFC_INTEGER_8);
+ sstride0 = pstride[0];
}
}
source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
- if (rs != source_extent)
+ if (rs < source_extent || (rs > source_extent && !pad))
runtime_error("Incorrect size in SOURCE argument to RESHAPE"
" intrinsic: is %ld, should be %ld",
(long int) source_extent, (long int) rs);
if (sempty)
{
- /* Switch immediately to the pad array. */
+ /* Pretend we are using the pad array the first time around, too. */
src = pptr;
- sptr = NULL;
+ sptr = pptr;
sdim = pdim;
for (dim = 0; dim < pdim; dim++)
{
scount[dim] = pcount[dim];
sextent[dim] = pextent[dim];
sstride[dim] = pstride[dim];
- sstride0 = sstride[0] * sizeof (GFC_REAL_10);
+ sstride0 = pstride[0];
}
}
source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
- if (rs != source_extent)
+ if (rs < source_extent || (rs > source_extent && !pad))
runtime_error("Incorrect size in SOURCE argument to RESHAPE"
" intrinsic: is %ld, should be %ld",
(long int) source_extent, (long int) rs);
if (sempty)
{
- /* Switch immediately to the pad array. */
+ /* Pretend we are using the pad array the first time around, too. */
src = pptr;
- sptr = NULL;
+ sptr = pptr;
sdim = pdim;
for (dim = 0; dim < pdim; dim++)
{
scount[dim] = pcount[dim];
sextent[dim] = pextent[dim];
sstride[dim] = pstride[dim];
- sstride0 = sstride[0] * sizeof (GFC_REAL_16);
+ sstride0 = pstride[0];
}
}
source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
- if (rs != source_extent)
+ if (rs < source_extent || (rs > source_extent && !pad))
runtime_error("Incorrect size in SOURCE argument to RESHAPE"
" intrinsic: is %ld, should be %ld",
(long int) source_extent, (long int) rs);
if (sempty)
{
- /* Switch immediately to the pad array. */
+ /* Pretend we are using the pad array the first time around, too. */
src = pptr;
- sptr = NULL;
+ sptr = pptr;
sdim = pdim;
for (dim = 0; dim < pdim; dim++)
{
scount[dim] = pcount[dim];
sextent[dim] = pextent[dim];
sstride[dim] = pstride[dim];
- sstride0 = sstride[0] * sizeof (GFC_REAL_4);
+ sstride0 = pstride[0];
}
}
source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
- if (rs != source_extent)
+ if (rs < source_extent || (rs > source_extent && !pad))
runtime_error("Incorrect size in SOURCE argument to RESHAPE"
" intrinsic: is %ld, should be %ld",
(long int) source_extent, (long int) rs);
if (sempty)
{
- /* Switch immediately to the pad array. */
+ /* Pretend we are using the pad array the first time around, too. */
src = pptr;
- sptr = NULL;
+ sptr = pptr;
sdim = pdim;
for (dim = 0; dim < pdim; dim++)
{
scount[dim] = pcount[dim];
sextent[dim] = pextent[dim];
sstride[dim] = pstride[dim];
- sstride0 = sstride[0] * sizeof (GFC_REAL_8);
+ sstride0 = pstride[0];
}
}
source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
- if (rs != source_extent)
+ if (rs < source_extent || (rs > source_extent && !pad))
runtime_error("Incorrect size in SOURCE argument to RESHAPE"
" intrinsic: is %ld, should be %ld",
(long int) source_extent, (long int) rs);
if (sempty)
{
- /* Switch immediately to the pad array. */
+ /* Pretend we are using the pad array the first time around, too. */
src = pptr;
- sptr = NULL;
+ sptr = pptr;
sdim = pdim;
for (dim = 0; dim < pdim; dim++)
{
scount[dim] = pcount[dim];
sextent[dim] = pextent[dim];
sstride[dim] = pstride[dim];
- sstride0 = sstride[0] * size;
+ sstride0 = pstride[0] * size;
}
}
source_extent = source->dim[0].ubound + 1 - source->dim[0].lbound;
- if (rs != source_extent)
+ if (rs < source_extent || (rs > source_extent && !pad))
runtime_error("Incorrect size in SOURCE argument to RESHAPE"
" intrinsic: is %ld, should be %ld",
(long int) source_extent, (long int) rs);
if (sempty)
{
- /* Switch immediately to the pad array. */
+ /* Pretend we are using the pad array the first time around, too. */
src = pptr;
- sptr = NULL;
+ sptr = pptr;
sdim = pdim;
for (dim = 0; dim < pdim; dim++)
{
scount[dim] = pcount[dim];
sextent[dim] = pextent[dim];
sstride[dim] = pstride[dim];
- sstride0 = sstride[0] * sizeof ('rtype_name`);
+ sstride0 = pstride[0];
}
}