This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gfortran] Change argument passing
- From: Paul Brook <paul at nowt dot org>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Cc: zhao ke <kejia_zh at yahoo dot com dot cn>
- Date: Sun, 30 Nov 2003 15:51:12 +0000
- Subject: [gfortran] Change argument passing
Attached patch passes array g77 style where possible, even when an explicit
interface is known. I've annother patch queued which depends on this one,
so I'm applying it now.
Tested on i686-linux.
Applied to tree-ssa branch.
Paul
2003-11-30 Kejia Zhao <kejia_zh@nudt.edu.cn>
* trans-array.c (gfc_conv_array_parameter): Simplify
array argument passing for array name actual argument.
* trans-expr.c (gfc_conv_function_call): Ditto
* trans-types.c (gfc_is_nodesc_array):Ditto.
diff -urpxCVS clean/tree-ssa/gcc/fortran/trans-array.c new-gcc/gcc/fortran/trans-array.c
--- clean/tree-ssa/gcc/fortran/trans-array.c 2003-11-27 19:17:10.000000000 +0000
+++ new-gcc/gcc/fortran/trans-array.c 2003-11-30 14:59:50.000000000 +0000
@@ -3736,8 +3736,38 @@ gfc_conv_array_parameter (gfc_se * se, g
tree desc;
tree tmp;
tree stmt;
+ gfc_symbol *sym;
stmtblock_t block;
+ /* Passing address of the array if it is not pointer or assumed-shape. */
+ if (expr->expr_type == EXPR_VARIABLE
+ && expr->ref->u.ar.type == AR_FULL && g77)
+ {
+ sym = expr->symtree->n.sym;
+ tmp = gfc_get_symbol_decl (sym);
+ if (!sym->attr.pointer && sym->as->type != AS_ASSUMED_SHAPE
+ && !sym->attr.allocatable && !sym->attr.in_common)
+ {
+ if (!sym->attr.dummy)
+ se->expr = build1 (ADDR_EXPR,
+ build_pointer_type (TREE_TYPE (tmp)),
+ tmp);
+ else
+ se->expr = tmp;
+ return;
+ }
+ if (sym->attr.allocatable)
+ {
+ se->expr = gfc_conv_array_data (tmp);
+ return;
+ }
+ if (sym->attr.in_common)
+ {
+ se->expr = TREE_OPERAND (tmp, 0);
+ return;
+ }
+ }
+
se->want_pointer = 1;
gfc_conv_expr_descriptor (se, expr, ss);
diff -urpxCVS clean/tree-ssa/gcc/fortran/trans-expr.c new-gcc/gcc/fortran/trans-expr.c
--- clean/tree-ssa/gcc/fortran/trans-expr.c 2003-11-28 16:15:23.000000000 +0000
+++ new-gcc/gcc/fortran/trans-expr.c 2003-11-30 14:44:19.000000000 +0000
@@ -1034,8 +1034,7 @@ gfc_conv_function_call (gfc_se * se, gfc
formal = sym->formal;
/* Use g77 calling convention if neccessary. */
- g77 = (gfc_option.flag_g77_calls
- && !sym->attr.always_explicit);
+ g77 = (gfc_option.flag_g77_calls);
/* Evaluate the arguments. */
for (; arg != NULL; arg = arg->next, formal = formal ? formal->next : NULL)
{
@@ -1090,7 +1089,19 @@ gfc_conv_function_call (gfc_se * se, gfc
}
}
else
- gfc_conv_array_parameter (&parmse, arg->expr, argss, g77);
+ {
+ /* If the procedure requires explicit interface, actual argument
+ is passed according to corresponing formal argument. We
+ do not use g77 method and the address of array descriptor
+ is passed if corresponing formal is pointer or
+ assumed-shape, Otherwise use g77 method. */
+ int f;
+ f = (formal != NULL)
+ && !formal->sym->attr.pointer
+ && formal->sym->as->type != AS_ASSUMED_SHAPE;
+ f = g77 && (f || !sym->attr.always_explicit);
+ gfc_conv_array_parameter (&parmse, arg->expr, argss, f);
+ }
}
gfc_add_block_to_block (&se->pre, &parmse.pre);
diff -urpxCVS clean/tree-ssa/gcc/fortran/trans-types.c new-gcc/gcc/fortran/trans-types.c
--- clean/tree-ssa/gcc/fortran/trans-types.c 2003-11-28 16:15:23.000000000 +0000
+++ new-gcc/gcc/fortran/trans-types.c 2003-11-30 14:31:12.000000000 +0000
@@ -461,8 +461,7 @@ gfc_is_nodesc_array (gfc_symbol * sym)
if (sym->attr.dummy)
{
- if (gfc_option.flag_g77_calls
- && !sym->ns->proc_name->attr.always_explicit)
+ if (gfc_option.flag_g77_calls && sym->as->type != AS_ASSUMED_SHAPE)
return 1;
else
return 0;