From 686c82b505d95d57302821df084c751b9528cea7 Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Fri, 13 Feb 2009 21:12:34 +0000 Subject: re PR fortran/36703 (ICE (segfault) in reduce_binary0 (arith.c:1778)) 2009-02-13 Paul Thomas PR fortran/36703 PR fortran/36528 * trans-expr.c (gfc_conv_function_val): Stabilize Cray-pointer function references to ensure that a valid expression is used. (gfc_conv_function_call): Pass Cray pointers to procedures. 2009-02-13 Paul Thomas PR fortran/36528 * gfortran.dg/cray_pointers_8.f90: New test. PR fortran/36703 * gfortran.dg/cray_pointers_9.f90: New test. From-SVN: r144164 --- gcc/fortran/ChangeLog | 8 ++++++++ gcc/fortran/trans-expr.c | 25 ++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 4655ffe..589db07 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2009-02-13 Paul Thomas + + PR fortran/36703 + PR fortran/36528 + * trans-expr.c (gfc_conv_function_val): Stabilize Cray-pointer + function references to ensure that a valid expression is used. + (gfc_conv_function_call): Pass Cray pointers to procedures. + 2009-02-03 Jakub Jelinek * gfortranspec.c (lang_specific_driver): Update copyright notice diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 5d41145..f0434b2 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -1505,9 +1505,17 @@ gfc_conv_function_val (gfc_se * se, gfc_symbol * sym) sym->backend_decl = gfc_get_extern_function_decl (sym); tmp = sym->backend_decl; + if (sym->attr.cray_pointee) - tmp = convert (build_pointer_type (TREE_TYPE (tmp)), - gfc_get_symbol_decl (sym->cp_pointer)); + { + /* TODO - make the cray pointee a pointer to a procedure, + assign the pointer to it and use it for the call. This + will do for now! */ + tmp = convert (build_pointer_type (TREE_TYPE (tmp)), + gfc_get_symbol_decl (sym->cp_pointer)); + tmp = gfc_evaluate_now (tmp, &se->pre); + } + if (!POINTER_TYPE_P (TREE_TYPE (tmp))) { gcc_assert (TREE_CODE (tmp) == FUNCTION_DECL); @@ -2623,7 +2631,18 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym, if (argss == gfc_ss_terminator) { - if (fsym && fsym->attr.value) + if (e->expr_type == EXPR_VARIABLE + && e->symtree->n.sym->attr.cray_pointee + && fsym && fsym->attr.flavor == FL_PROCEDURE) + { + /* The Cray pointer needs to be converted to a pointer to + a type given by the expression. */ + gfc_conv_expr (&parmse, e); + type = build_pointer_type (TREE_TYPE (parmse.expr)); + tmp = gfc_get_symbol_decl (e->symtree->n.sym->cp_pointer); + parmse.expr = convert (type, tmp); + } + else if (fsym && fsym->attr.value) { if (fsym->ts.type == BT_CHARACTER && fsym->ts.is_c_interop -- cgit v1.1