* gfortran.h (gfc_get_proc_ptr_comp): New prototype.
(gfc_is_proc_ptr_comp): Update prototype.
* expr.c (gfc_get_proc_ptr_comp): New function based on the old
gfc_is_proc_ptr_comp.
(gfc_is_proc_ptr_comp): Call gfc_get_proc_ptr_comp.
(gfc_specification_expr, gfc_check_pointer_assign): Use
gfc_get_proc_ptr_comp.
* trans-array.c (gfc_walk_function_expr): Likewise.
* resolve.c (resolve_structure_cons, update_ppc_arglist,
resolve_ppc_call, resolve_expr_ppc): Likewise.
(resolve_function): Update call to gfc_is_proc_ptr_comp.
* dump-parse-tree.c (show_expr): Likewise.
* interface.c (compare_actual_formal): Likewise.
* match.c (gfc_match_pointer_assignment): Likewise.
* primary.c (gfc_match_varspec): Likewise.
* trans-io.c (gfc_trans_transfer): Likewise.
* trans-expr.c (gfc_conv_variable, conv_function_val,
conv_isocbinding_procedure, gfc_conv_procedure_call,
gfc_trans_pointer_assignment): Likewise.
(gfc_conv_procedure_call, gfc_trans_array_func_assign):
Use gfc_get_proc_ptr_comp.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@190391
138bc75d-0d04-0410-961f-
82ee72b054a4
+2012-08-14 Mikael Morin <mikael@gcc.gnu.org>
+
+ * gfortran.h (gfc_get_proc_ptr_comp): New prototype.
+ (gfc_is_proc_ptr_comp): Update prototype.
+ * expr.c (gfc_get_proc_ptr_comp): New function based on the old
+ gfc_is_proc_ptr_comp.
+ (gfc_is_proc_ptr_comp): Call gfc_get_proc_ptr_comp.
+ (gfc_specification_expr, gfc_check_pointer_assign): Use
+ gfc_get_proc_ptr_comp.
+ * trans-array.c (gfc_walk_function_expr): Likewise.
+ * resolve.c (resolve_structure_cons, update_ppc_arglist,
+ resolve_ppc_call, resolve_expr_ppc): Likewise.
+ (resolve_function): Update call to gfc_is_proc_ptr_comp.
+ * dump-parse-tree.c (show_expr): Likewise.
+ * interface.c (compare_actual_formal): Likewise.
+ * match.c (gfc_match_pointer_assignment): Likewise.
+ * primary.c (gfc_match_varspec): Likewise.
+ * trans-io.c (gfc_trans_transfer): Likewise.
+ * trans-expr.c (gfc_conv_variable, conv_function_val,
+ conv_isocbinding_procedure, gfc_conv_procedure_call,
+ gfc_trans_pointer_assignment): Likewise.
+ (gfc_conv_procedure_call, gfc_trans_array_func_assign):
+ Use gfc_get_proc_ptr_comp.
+
2012-08-14 Tobias Burnus <burnus@net-b.de>
PR fortran/40881
if (p->value.function.name == NULL)
{
fprintf (dumpfile, "%s", p->symtree->n.sym->name);
- if (gfc_is_proc_ptr_comp (p, NULL))
+ if (gfc_is_proc_ptr_comp (p))
show_ref (p->ref);
fputc ('[', dumpfile);
show_actual_arglist (p->value.function.actual);
else
{
fprintf (dumpfile, "%s", p->value.function.name);
- if (gfc_is_proc_ptr_comp (p, NULL))
+ if (gfc_is_proc_ptr_comp (p))
show_ref (p->ref);
fputc ('[', dumpfile);
fputc ('[', dumpfile);
return FAILURE;
}
+ comp = gfc_get_proc_ptr_comp (e);
if (e->expr_type == EXPR_FUNCTION
- && !e->value.function.isym
- && !e->value.function.esym
- && !gfc_pure (e->symtree->n.sym)
- && (!gfc_is_proc_ptr_comp (e, &comp)
- || !comp->attr.pure))
+ && !e->value.function.isym
+ && !e->value.function.esym
+ && !gfc_pure (e->symtree->n.sym)
+ && (!comp || !comp->attr.pure))
{
gfc_error ("Function '%s' at %L must be PURE",
e->symtree->n.sym->name, &e->where);
}
}
- if (gfc_is_proc_ptr_comp (lvalue, &comp))
+ comp = gfc_get_proc_ptr_comp (lvalue);
+ if (comp)
s1 = comp->ts.interface;
else
s1 = lvalue->symtree->n.sym;
- if (gfc_is_proc_ptr_comp (rvalue, &comp))
+ comp = gfc_get_proc_ptr_comp (rvalue);
+ if (comp)
{
s2 = comp->ts.interface;
name = comp->name;
}
-/* Determine if an expression is a procedure pointer component. If yes, the
- argument 'comp' will point to the component (provided that 'comp' was
- provided). */
+/* Determine if an expression is a procedure pointer component and return
+ the component in that case. Otherwise return NULL. */
-bool
-gfc_is_proc_ptr_comp (gfc_expr *expr, gfc_component **comp)
+gfc_component *
+gfc_get_proc_ptr_comp (gfc_expr *expr)
{
gfc_ref *ref;
- bool ppc = false;
if (!expr || !expr->ref)
- return false;
+ return NULL;
ref = expr->ref;
while (ref->next)
ref = ref->next;
- if (ref->type == REF_COMPONENT)
- {
- ppc = ref->u.c.component->attr.proc_pointer;
- if (ppc && comp)
- *comp = ref->u.c.component;
- }
+ if (ref->type == REF_COMPONENT
+ && ref->u.c.component->attr.proc_pointer)
+ return ref->u.c.component;
+
+ return NULL;
+}
+
- return ppc;
+/* Determine if an expression is a procedure pointer component. */
+
+bool
+gfc_is_proc_ptr_comp (gfc_expr *expr)
+{
+ return (gfc_get_proc_ptr_comp (expr) != NULL);
}
void gfc_expr_replace_symbols (gfc_expr *, gfc_symbol *);
void gfc_expr_replace_comp (gfc_expr *, gfc_component *);
-bool gfc_is_proc_ptr_comp (gfc_expr *, gfc_component **);
+gfc_component * gfc_get_proc_ptr_comp (gfc_expr *);
+bool gfc_is_proc_ptr_comp (gfc_expr *);
bool gfc_ref_this_image (gfc_ref *ref);
bool gfc_is_coindexed (gfc_expr *);
&& a->expr->symtree->n.sym->attr.proc_pointer)
|| (a->expr->expr_type == EXPR_FUNCTION
&& a->expr->symtree->n.sym->result->attr.proc_pointer)
- || gfc_is_proc_ptr_comp (a->expr, NULL)))
+ || gfc_is_proc_ptr_comp (a->expr)))
{
if (where)
gfc_error ("Expected a procedure pointer for argument '%s' at %L",
/* Satisfy 12.4.1.2 by ensuring that a procedure actual argument is
provided for a procedure formal argument. */
- if (a->expr->ts.type != BT_PROCEDURE && !gfc_is_proc_ptr_comp (a->expr, NULL)
+ if (a->expr->ts.type != BT_PROCEDURE && !gfc_is_proc_ptr_comp (a->expr)
&& a->expr->expr_type == EXPR_VARIABLE
&& f->sym->attr.flavor == FL_PROCEDURE)
{
}
if (lvalue->symtree->n.sym->attr.proc_pointer
- || gfc_is_proc_ptr_comp (lvalue, NULL))
+ || gfc_is_proc_ptr_comp (lvalue))
gfc_matching_procptr_assignment = 1;
else
gfc_matching_ptr_assignment = 1;
if ((equiv_flag && gfc_peek_ascii_char () == '(')
|| gfc_peek_ascii_char () == '[' || sym->attr.codimension
|| (sym->attr.dimension && sym->ts.type != BT_CLASS
- && !sym->attr.proc_pointer && !gfc_is_proc_ptr_comp (primary, NULL)
+ && !sym->attr.proc_pointer && !gfc_is_proc_ptr_comp (primary)
&& !(gfc_matching_procptr_assignment
&& sym->attr.flavor == FL_PROCEDURE))
|| (sym->ts.type == BT_CLASS && sym->attr.class_ok
const char *name;
char err[200];
- if (gfc_is_proc_ptr_comp (cons->expr, &c2))
+ c2 = gfc_get_proc_ptr_comp (cons->expr);
+ if (c2)
{
s2 = c2->ts.interface;
name = c2->name;
sym = expr->symtree->n.sym;
/* If this is a procedure pointer component, it has already been resolved. */
- if (gfc_is_proc_ptr_comp (expr, NULL))
+ if (gfc_is_proc_ptr_comp (expr))
return SUCCESS;
-
+
if (sym && sym->attr.intrinsic
&& gfc_resolve_intrinsic (sym, &expr->where) == FAILURE)
return FAILURE;
gfc_component *ppc;
gfc_typebound_proc* tb;
- if (!gfc_is_proc_ptr_comp (e, &ppc))
+ ppc = gfc_get_proc_ptr_comp (e);
+ if (!ppc)
return FAILURE;
tb = ppc->tb;
resolve_ppc_call (gfc_code* c)
{
gfc_component *comp;
- bool b;
- b = gfc_is_proc_ptr_comp (c->expr1, &comp);
- gcc_assert (b);
+ comp = gfc_get_proc_ptr_comp (c->expr1);
+ gcc_assert (comp != NULL);
c->resolved_sym = c->expr1->symtree->n.sym;
c->expr1->expr_type = EXPR_VARIABLE;
resolve_expr_ppc (gfc_expr* e)
{
gfc_component *comp;
- bool b;
- b = gfc_is_proc_ptr_comp (e, &comp);
- gcc_assert (b);
+ comp = gfc_get_proc_ptr_comp (e);
+ gcc_assert (comp != NULL);
/* Convert to EXPR_FUNCTION. */
e->expr_type = EXPR_FUNCTION;
sym = expr->symtree->n.sym;
/* A function that returns arrays. */
- gfc_is_proc_ptr_comp (expr, &comp);
+ comp = gfc_get_proc_ptr_comp (expr);
if ((!comp && gfc_return_by_reference (sym) && sym->result->attr.dimension)
|| (comp && comp->attr.dimension))
return gfc_get_array_ss (ss, expr, expr->rank, GFC_SS_FUNCTION);
separately. */
if (se->want_pointer)
{
- if (expr->ts.type == BT_CHARACTER && !gfc_is_proc_ptr_comp (expr, NULL))
+ if (expr->ts.type == BT_CHARACTER && !gfc_is_proc_ptr_comp (expr))
gfc_conv_string_parameter (se);
- else
+ else
se->expr = gfc_build_addr_expr (NULL_TREE, se->expr);
}
}
{
tree tmp;
- if (gfc_is_proc_ptr_comp (expr, NULL))
+ if (gfc_is_proc_ptr_comp (expr))
tmp = get_proc_ptr_comp (expr);
else if (sym->attr.dummy)
{
if (arg->next->expr->rank == 0)
{
if (sym->intmod_sym_id == ISOCBINDING_F_POINTER
- || gfc_is_proc_ptr_comp (arg->next->expr, NULL))
+ || gfc_is_proc_ptr_comp (arg->next->expr))
fptrse.want_pointer = 1;
gfc_conv_expr (&fptrse, arg->next->expr);
&& conv_isocbinding_procedure (se, sym, args))
return 0;
- gfc_is_proc_ptr_comp (expr, &comp);
+ comp = gfc_get_proc_ptr_comp (expr);
if (se->ss != NULL)
{
&& e->symtree->n.sym->attr.dummy))
|| (fsym->attr.proc_pointer
&& e->expr_type == EXPR_VARIABLE
- && gfc_is_proc_ptr_comp (e, NULL))
+ && gfc_is_proc_ptr_comp (e))
|| (fsym->attr.allocatable
&& fsym->attr.flavor != FL_PROCEDURE)))
{
if (expr1->ts.type == BT_CHARACTER && expr2->expr_type != EXPR_NULL
&& !expr1->ts.deferred
&& !expr1->symtree->n.sym->attr.proc_pointer
- && !gfc_is_proc_ptr_comp (expr1, NULL))
+ && !gfc_is_proc_ptr_comp (expr1))
{
gcc_assert (expr2->ts.type == BT_CHARACTER);
gcc_assert (lse.string_length && rse.string_length);
/* The frontend doesn't seem to bother filling in expr->symtree for intrinsic
functions. */
+ comp = gfc_get_proc_ptr_comp (expr2);
gcc_assert (expr2->value.function.isym
- || (gfc_is_proc_ptr_comp (expr2, &comp)
- && comp && comp->attr.dimension)
+ || (comp && comp->attr.dimension)
|| (!comp && gfc_return_by_reference (expr2->value.function.esym)
&& expr2->value.function.esym->result->attr.dimension));
/* Transfer an array. If it is an array of an intrinsic
type, pass the descriptor to the library. Otherwise
scalarize the transfer. */
- if (expr->ref && !gfc_is_proc_ptr_comp (expr, NULL))
+ if (expr->ref && !gfc_is_proc_ptr_comp (expr))
{
for (ref = expr->ref; ref && ref->type != REF_ARRAY;
ref = ref->next);