diff options
author | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-22 10:38:09 +0000 |
---|---|---|
committer | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-22 10:38:09 +0000 |
commit | 7eb1e18e8e0b04719534592d8142c47ff4af9495 (patch) | |
tree | 6d75073bdeaba189f447c9d503bf807a5f7c390d /gcc/fortran/frontend-passes.c | |
parent | ca8206e47cd128aded9844862dd870ae563e39de (diff) | |
download | gcc-7eb1e18e8e0b04719534592d8142c47ff4af9495.tar.gz |
2011-05-22 Thomas Koenig <tkoenig@gcc.gnu.org>
* frontend-passes.c (cfe_register_funcs): Also register
character functions if their charlens are known and constant.
Also register allocatable functions.
2011-05-22 Thomas Koenig <tkoenig@gcc.gnu.org>
* gfortran.dg/function_optimize_8.f90: New test case.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@174027 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/frontend-passes.c')
-rw-r--r-- | gcc/fortran/frontend-passes.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index 186cbb43304..0137a9ddbf2 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -137,8 +137,7 @@ optimize_expr (gfc_expr **e, int *walk_subtrees ATTRIBUTE_UNUSED, /* Callback function for common function elimination, called from cfe_expr_0. - Put all eligible function expressions into expr_array. We can't do - allocatable functions. */ + Put all eligible function expressions into expr_array. */ static int cfe_register_funcs (gfc_expr **e, int *walk_subtrees ATTRIBUTE_UNUSED, @@ -148,8 +147,10 @@ cfe_register_funcs (gfc_expr **e, int *walk_subtrees ATTRIBUTE_UNUSED, if ((*e)->expr_type != EXPR_FUNCTION) return 0; - /* We don't do character functions (yet). */ - if ((*e)->ts.type == BT_CHARACTER) + /* We don't do character functions with unknown charlens. */ + if ((*e)->ts.type == BT_CHARACTER + && ((*e)->ts.u.cl == NULL || (*e)->ts.u.cl->length == NULL + || (*e)->ts.u.cl->length->expr_type != EXPR_CONSTANT)) return 0; /* If we don't know the shape at compile time, we create an allocatable @@ -163,9 +164,6 @@ cfe_register_funcs (gfc_expr **e, int *walk_subtrees ATTRIBUTE_UNUSED, is specified. */ if ((*e)->value.function.esym) { - if ((*e)->value.function.esym->attr.allocatable) - return 0; - /* Don't create an array temporary for elemental functions. */ if ((*e)->value.function.esym->attr.elemental && (*e)->rank > 0) return 0; @@ -181,9 +179,10 @@ cfe_register_funcs (gfc_expr **e, int *walk_subtrees ATTRIBUTE_UNUSED, if ((*e)->value.function.isym) { /* Conversions are handled on the fly by the middle end, - transpose during trans-* stages. */ + transpose during trans-* stages and TRANSFER by the middle end. */ if ((*e)->value.function.isym->id == GFC_ISYM_CONVERSION - || (*e)->value.function.isym->id == GFC_ISYM_TRANSPOSE) + || (*e)->value.function.isym->id == GFC_ISYM_TRANSPOSE + || (*e)->value.function.isym->id == GFC_ISYM_TRANSFER) return 0; /* Don't create an array temporary for elemental functions, |