From: Tobias Schlüter Date: Sat, 22 May 2004 13:31:07 +0000 (+0000) Subject: trans-decl.c (gfc_get_extern_function_decl): Set DECL_IS_PURE only for functions. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b7e6a6b3f511cc8aabb80a4460c417fcac90c2e7;p=gcc.git trans-decl.c (gfc_get_extern_function_decl): Set DECL_IS_PURE only for functions. * trans-decl.c (gfc_get_extern_function_decl): Set DECL_IS_PURE only for functions. (gfc_build_function_decl): Likewise. From-SVN: r82132 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f2c23546bbc..3d0d427b78a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2004-05-22 Tobias Schlüter + + * trans-decl.c (gfc_get_extern_function_decl): Set DECL_IS_PURE + only for functions. + (gfc_build_function_decl): Likewise. + 2004-05-22 Steven G. Kargl * check.c (gfc_check_system_clock): New function. diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 8708bea14b1..32dfdc4a643 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -951,9 +951,13 @@ gfc_get_extern_function_decl (gfc_symbol * sym) sense. */ if (sym->attr.pure || sym->attr.elemental) { - DECL_IS_PURE (fndecl) = 1; -/* TODO: check if pure/elemental procedures can have INTENT(OUT) parameters. - TREE_SIDE_EFFECTS (fndecl) = 0;*/ + if (sym->attr.function) + DECL_IS_PURE (fndecl) = 1; + /* TODO: check if pure SUBROUTINEs don't have INTENT(OUT) + parameters and don't use alternate returns (is this + allowed?). In that case, calls to them are meaningless, and + can be optimized away. See also in gfc_build_function_decl(). */ + TREE_SIDE_EFFECTS (fndecl) = 0; } sym->backend_decl = fndecl; @@ -1060,7 +1064,11 @@ gfc_build_function_decl (gfc_symbol * sym) sense. */ if (attr.pure || attr.elemental) { - DECL_IS_PURE (fndecl) = 1; + /* TODO: check if a pure SUBROUTINE has no INTENT(OUT) arguments + including a alternate return. In that case it can also be + marked as PURE. See also in gfc_get_extern_fucntion_decl(). */ + if (attr.function) + DECL_IS_PURE (fndecl) = 1; TREE_SIDE_EFFECTS (fndecl) = 0; }