mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-29 07:00:24 +08:00
re PR fortran/45159 (Unnecessary temporaries)
2010-09-03 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/45159 * dependency.c (gfc_deb_compare_expr): Compare equal for equal arglists for pure user functions, or for those intrinsic functions which are also pure. * intrinsics.c (add_conv): Mark conversion functions as pure. (add_char_conversions): Likewise. 2010-09-03 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/45159 * gfortran.dg/dependency_34.f90: New test. From-SVN: r163834
This commit is contained in:
parent
de3f621b74
commit
124a8ce610
gcc
@ -1,3 +1,12 @@
|
||||
2010-09-03 Thomas Koenig <tkoenig@gcc.gnu.org>
|
||||
|
||||
PR fortran/45159
|
||||
* dependency.c (gfc_deb_compare_expr): Compare equal for equal
|
||||
arglists for pure user functions, or for those intrinsic
|
||||
functions which are also pure.
|
||||
* intrinsics.c (add_conv): Mark conversion functions as pure.
|
||||
(add_char_conversions): Likewise.
|
||||
|
||||
2010-09-03 Daniel Kraft <d@domob.eu>
|
||||
|
||||
PR fortran/34162
|
||||
|
@ -353,39 +353,32 @@ gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2)
|
||||
return -2;
|
||||
|
||||
case EXPR_FUNCTION:
|
||||
/* We can only compare calls to the same intrinsic function. */
|
||||
if (e1->value.function.isym == 0 || e2->value.function.isym == 0
|
||||
|| e1->value.function.isym != e2->value.function.isym)
|
||||
|
||||
/* PURE functions can be compared for argument equality. */
|
||||
if ((e1->value.function.esym && e2->value.function.esym
|
||||
&& e1->value.function.esym == e2->value.function.esym
|
||||
&& e1->value.function.esym->result->attr.pure)
|
||||
|| (e1->value.function.isym && e2->value.function.isym
|
||||
&& e1->value.function.isym == e2->value.function.isym
|
||||
&& e1->value.function.isym->pure))
|
||||
{
|
||||
args1 = e1->value.function.actual;
|
||||
args2 = e2->value.function.actual;
|
||||
|
||||
/* Compare the argument lists for equality. */
|
||||
while (args1 && args2)
|
||||
{
|
||||
if (gfc_dep_compare_expr (args1->expr, args2->expr) != 0)
|
||||
return -2;
|
||||
args1 = args1->next;
|
||||
args2 = args2->next;
|
||||
}
|
||||
return (args1 || args2) ? -2 : 0;
|
||||
}
|
||||
else
|
||||
return -2;
|
||||
break;
|
||||
|
||||
args1 = e1->value.function.actual;
|
||||
args2 = e2->value.function.actual;
|
||||
|
||||
/* We should list the "constant" intrinsic functions. Those
|
||||
without side-effects that provide equal results given equal
|
||||
argument lists. */
|
||||
switch (e1->value.function.isym->id)
|
||||
{
|
||||
|
||||
case GFC_ISYM_REAL:
|
||||
case GFC_ISYM_LOGICAL:
|
||||
case GFC_ISYM_DBLE:
|
||||
break;
|
||||
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* Compare the argument lists for equality. */
|
||||
while (args1 && args2)
|
||||
{
|
||||
if (gfc_dep_compare_expr (args1->expr, args2->expr) != 0)
|
||||
return -2;
|
||||
args1 = args1->next;
|
||||
args2 = args2->next;
|
||||
}
|
||||
return (args1 || args2) ? -2 : 0;
|
||||
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
|
@ -3060,6 +3060,7 @@ add_conv (bt from_type, int from_kind, bt to_type, int to_kind, int standard)
|
||||
sym->simplify.cc = gfc_convert_constant;
|
||||
sym->standard = standard;
|
||||
sym->elemental = 1;
|
||||
sym->pure = 1;
|
||||
sym->conversion = 1;
|
||||
sym->ts = to;
|
||||
sym->id = GFC_ISYM_CONVERSION;
|
||||
@ -3210,6 +3211,7 @@ add_char_conversions (void)
|
||||
char_conversions[n].simplify.cc = gfc_convert_char_constant;
|
||||
char_conversions[n].standard = GFC_STD_F2003;
|
||||
char_conversions[n].elemental = 1;
|
||||
char_conversions[n].pure = 1;
|
||||
char_conversions[n].conversion = 0;
|
||||
char_conversions[n].ts = to;
|
||||
char_conversions[n].id = GFC_ISYM_CONVERSION;
|
||||
|
@ -1,3 +1,8 @@
|
||||
2010-09-03 Thomas Koenig <tkoenig@gcc.gnu.org>
|
||||
|
||||
PR fortran/45159
|
||||
* gfortran.dg/dependency_34.f90: New test.
|
||||
|
||||
2010-09-03 Steve Ellcey <sje@cup.hp.com>
|
||||
|
||||
* gcc.dg/torture/pr44806.c: Add -std=c99 to access uint32_t.
|
||||
|
22
gcc/testsuite/gfortran.dg/dependency_34.f90
Normal file
22
gcc/testsuite/gfortran.dg/dependency_34.f90
Normal file
@ -0,0 +1,22 @@
|
||||
! { dg-do compile }
|
||||
! { dg-options "-Warray-temporaries" }
|
||||
module foo
|
||||
implicit none
|
||||
contains
|
||||
integer pure function bar(i,j)
|
||||
integer, intent(in) :: i,j
|
||||
bar = 3 - i + 1 * abs(i) + j
|
||||
end function bar
|
||||
end module foo
|
||||
|
||||
program main
|
||||
use foo
|
||||
implicit none
|
||||
real a(10)
|
||||
integer :: i
|
||||
read (*,*) a, i
|
||||
a(i:abs(i)) = a(i:abs(i))
|
||||
a(bar(i,i+2):2) = a(bar(i,i+2):2)
|
||||
a(int(i,kind=2):5) = a(int(i,kind=2)+1:6)
|
||||
end program main
|
||||
! { dg-final { cleanup-modules "foo" } }
|
Loading…
x
Reference in New Issue
Block a user