This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch, fortran, committed] Fix PR 34817 and PR 34838
- From: Thomas Koenig <tkoenig at netcologne dot de>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Sat, 19 Jan 2008 23:51:39 +0100
- Subject: [patch, fortran, committed] Fix PR 34817 and PR 34838
Hello world,
I attached the patch below as obvious and simple (revision 131660). It
fixed two regressions introduced by my earlier patch for using
GFC_LOGICAL_1 for the any, count and all library functions.
Thomas
2008-01-19 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/34817
PR fortran/34838
* iresolve.c (gfc_resolve_all): Remove conversion of mask
argument to kind=1 by removing call to resolve_mask_arg().
(gfc_resolve_any): Likewise.
2008-01-19 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/34817
PR fortran/34838
* gfortran.dg/any_all_1.f90: New test.
* gfortran.dg/any_all_2.f90: New test.
Index: iresolve.c
===================================================================
--- iresolve.c (revision 131655)
+++ iresolve.c (working copy)
@@ -256,8 +256,6 @@ gfc_resolve_all (gfc_expr *f, gfc_expr *
f->shape = gfc_copy_shape_excluding (mask->shape, mask->rank, dim);
}
- resolve_mask_arg (mask);
-
f->value.function.name
= gfc_get_string (PREFIX ("all_%c%d"), gfc_type_letter (mask->ts.type),
mask->ts.kind);
@@ -306,8 +304,6 @@ gfc_resolve_any (gfc_expr *f, gfc_expr *
f->shape = gfc_copy_shape_excluding (mask->shape, mask->rank, dim);
}
- resolve_mask_arg (mask);
-
f->value.function.name
= gfc_get_string (PREFIX ("any_%c%d"), gfc_type_letter (mask->ts.type),
mask->ts.kind);
! { dg-do run }
! PR 34817 - the wrong library function was called,
! leading to garbage in the return value
program main
real, dimension(2,2) :: a
logical(kind=4), dimension(2) :: b
integer, dimension(2) :: i
equivalence (b,i)
data a /1.0, 2.0, -0.1, -0.2 /
i = 16843009 ! Initialize i to put junk into b
b = any(a>0.5,dim=1)
if (b(2) .or. .not. b(1)) call abort
i = 16843009 ! Initialize i to put junk into b
b = all(a>0.5,dim=1)
if (b(2) .or. .not. b(1)) call abort
end program main
! { dg-do compile }
! PR 34838 - this failed with "Can't convert LOGICAL(1) to LOGICAL(1)
! Test case contributed by Manfred Schwab.
program main
Logical(kind=1) :: bmp(1),bmpv(1)
bmp(1)=.false.
bmpv(1)=.true.
if ( ANY(bmp(1:1) .NEQV. bmpv(1:1)) ) then
print*,"hello"
end if
if ( ALL(bmp(1:1) .NEQV. bmpv(1:1)) ) then
print*,"hello"
end if
end program main