Commit ee440dd0 by Thomas Koenig

re PR libfortran/35001 (shape for negative sizes)

2008-02-02  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR libfortran/35001
	* m4/shape.m4:  Return 0 for extents <= 0.
	* generated/shape_i4.c:  Regenerated.
	* generated/shape_i8.c:  Regenerated.
	* generated/shape_i16.c:  Regenerated.

2008-02-02  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR libfortran/35001
	* gfortran.dg/shape_4.f90:  New test.

Fixed in regression-only mode by special dispense (see the PR).

From-SVN: r132070
parent 27f56cb1
2008-02-02 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/35001
* gfortran.dg/shape_4.f90: New test.
2008-02-02 Hans-Peter Nilsson <hp@axis.com> 2008-02-02 Hans-Peter Nilsson <hp@axis.com>
* gcc.target/cris/torture/pr34773.c: Use __asm__, not asm. * gcc.target/cris/torture/pr34773.c: Use __asm__, not asm.
! PR 35001 - we need to return 0 for the shapes of
! negative extents. Test case adapted from Tobias Burnus.
program main
implicit none
integer :: i,j, a(10,10),res(2)
j = 1
i = 10
res = shape(a(1:1,i:j:1))
if (res(1) /=1 .or. res(2) /= 0) call abort
res = shape(a(1:1,j:i:-1))
if (res(1) /=1 .or. res(2) /= 0) call abort
end program main
2008-02-02 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/35001
* m4/shape.m4: Return 0 for extents <= 0.
* generated/shape_i4.c: Regenerated.
* generated/shape_i8.c: Regenerated.
* generated/shape_i16.c: Regenerated.
2008-01-27 Thomas Koenig <tkoenig@gcc.gnu.org> 2008-01-27 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/34980 PR libfortran/34980
......
...@@ -45,6 +45,7 @@ shape_16 (gfc_array_i16 * const restrict ret, ...@@ -45,6 +45,7 @@ shape_16 (gfc_array_i16 * const restrict ret,
{ {
int n; int n;
index_type stride; index_type stride;
index_type extent;
stride = ret->dim[0].stride; stride = ret->dim[0].stride;
...@@ -53,8 +54,8 @@ shape_16 (gfc_array_i16 * const restrict ret, ...@@ -53,8 +54,8 @@ shape_16 (gfc_array_i16 * const restrict ret,
for (n = 0; n < GFC_DESCRIPTOR_RANK (array); n++) for (n = 0; n < GFC_DESCRIPTOR_RANK (array); n++)
{ {
ret->data[n * stride] = extent = array->dim[n].ubound + 1 - array->dim[n].lbound;
array->dim[n].ubound + 1 - array->dim[n].lbound; ret->data[n * stride] = extent > 0 ? extent : 0 ;
} }
} }
......
...@@ -45,6 +45,7 @@ shape_4 (gfc_array_i4 * const restrict ret, ...@@ -45,6 +45,7 @@ shape_4 (gfc_array_i4 * const restrict ret,
{ {
int n; int n;
index_type stride; index_type stride;
index_type extent;
stride = ret->dim[0].stride; stride = ret->dim[0].stride;
...@@ -53,8 +54,8 @@ shape_4 (gfc_array_i4 * const restrict ret, ...@@ -53,8 +54,8 @@ shape_4 (gfc_array_i4 * const restrict ret,
for (n = 0; n < GFC_DESCRIPTOR_RANK (array); n++) for (n = 0; n < GFC_DESCRIPTOR_RANK (array); n++)
{ {
ret->data[n * stride] = extent = array->dim[n].ubound + 1 - array->dim[n].lbound;
array->dim[n].ubound + 1 - array->dim[n].lbound; ret->data[n * stride] = extent > 0 ? extent : 0 ;
} }
} }
......
...@@ -45,6 +45,7 @@ shape_8 (gfc_array_i8 * const restrict ret, ...@@ -45,6 +45,7 @@ shape_8 (gfc_array_i8 * const restrict ret,
{ {
int n; int n;
index_type stride; index_type stride;
index_type extent;
stride = ret->dim[0].stride; stride = ret->dim[0].stride;
...@@ -53,8 +54,8 @@ shape_8 (gfc_array_i8 * const restrict ret, ...@@ -53,8 +54,8 @@ shape_8 (gfc_array_i8 * const restrict ret,
for (n = 0; n < GFC_DESCRIPTOR_RANK (array); n++) for (n = 0; n < GFC_DESCRIPTOR_RANK (array); n++)
{ {
ret->data[n * stride] = extent = array->dim[n].ubound + 1 - array->dim[n].lbound;
array->dim[n].ubound + 1 - array->dim[n].lbound; ret->data[n * stride] = extent > 0 ? extent : 0 ;
} }
} }
......
...@@ -46,6 +46,7 @@ shape_'rtype_kind` ('rtype` * const restrict ret, ...@@ -46,6 +46,7 @@ shape_'rtype_kind` ('rtype` * const restrict ret,
{ {
int n; int n;
index_type stride; index_type stride;
index_type extent;
stride = ret->dim[0].stride; stride = ret->dim[0].stride;
...@@ -54,8 +55,8 @@ shape_'rtype_kind` ('rtype` * const restrict ret, ...@@ -54,8 +55,8 @@ shape_'rtype_kind` ('rtype` * const restrict ret,
for (n = 0; n < GFC_DESCRIPTOR_RANK (array); n++) for (n = 0; n < GFC_DESCRIPTOR_RANK (array); n++)
{ {
ret->data[n * stride] = extent = array->dim[n].ubound + 1 - array->dim[n].lbound;
array->dim[n].ubound + 1 - array->dim[n].lbound; ret->data[n * stride] = extent > 0 ? extent : 0 ;
} }
} }
......
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