/* For valid expressions, check that the type specification parameters
are the same. */
- if (t && !c->iterator && c->expr
- && c->expr->ts.type == BT_DERIVED
- && c->expr->ts.u.derived->attr.pdt_type)
+ if (t && !c->iterator && c->expr && IS_PDT (c->expr))
{
if (expr1 == NULL)
expr1 = c->expr;
(expr && expr->expr_type == EXPR_VARIABLE \
&& expr->symtree->n.sym->assoc \
&& expr->symtree->n.sym->assoc->inferred_type)
+#define IS_PDT(sym) \
+ (sym != NULL && sym->ts.type == BT_DERIVED \
+ && sym->ts.u.derived \
+ && sym->ts.u.derived->attr.pdt_type)
+#define IS_CLASS_PDT(sym) \
+ (sym != NULL && sym->ts.type == BT_CLASS \
+ && CLASS_DATA (sym) \
+ && CLASS_DATA (sym)->ts.u.derived \
+ && CLASS_DATA (sym)->ts.u.derived->attr.pdt_type)
/* frontend-passes.cc */
return MATCH_ERROR;
}
- if (c->ts.type == BT_DERIVED
- && c->ts.u.derived && c->ts.u.derived->attr.pdt_type
- && gfc_spec_list_type (type_param_spec_list, c->ts.u.derived)
- != SPEC_ASSUMED)
+ if (IS_PDT (c) && gfc_spec_list_type (type_param_spec_list,
+ c->ts.u.derived) != SPEC_ASSUMED)
{
gfc_error ("All the LEN type parameters in the TYPE IS statement "
"at %C must be ASSUMED");
n_components = 0;
array_ref = NULL;
- if (expr->expr_type == EXPR_VARIABLE
- && expr->symtree->n.sym->ts.type == BT_DERIVED
- && expr->symtree->n.sym->ts.u.derived->attr.pdt_type)
+ if (expr->expr_type == EXPR_VARIABLE && IS_PDT (expr))
last_pdt = expr->symtree->n.sym->ts.u.derived;
for (ref = expr->ref; ref; ref = ref->next)
gfc_code *init_st;
gfc_namespace *ns = sym->ns;
- if (sym->attr.function && sym->result == sym
- && sym->ts.type == BT_DERIVED && sym->ts.u.derived->attr.pdt_type)
+ if (sym->attr.function && sym->result == sym && IS_PDT (sym))
{
gfc_free_expr (init);
return;
if (!sym->attr.pdt_type)
sym->attr.pdt_comp = 1;
}
- else if (c->ts.type == BT_DERIVED && c->ts.u.derived->attr.pdt_type
- && !sym->attr.pdt_type)
+ else if (IS_PDT (c) && !sym->attr.pdt_type)
sym->attr.pdt_comp = 1;
if (c->attr.proc_pointer && c->ts.interface)
{
/* Scalar values. */
gfc_init_se (&se, NULL);
- if (c->expr->ts.type == BT_DERIVED
- && c->expr->ts.u.derived->attr.pdt_type
- && c->expr->expr_type == EXPR_STRUCTURE)
+ if (IS_PDT (c->expr) && c->expr->expr_type == EXPR_STRUCTURE)
c->expr->must_finalize = 1;
gfc_trans_array_ctor_element (&body, desc, *poffset,
if (expr->ts.type == BT_DERIVED && expr->ts.u.derived->attr.alloc_comp)
finalize_required = true;
- if (expr->ts.type == BT_DERIVED && expr->ts.u.derived->attr.pdt_type)
+ if (IS_PDT (expr))
finalize_required = true;
gfc_trans_array_constructor_value (&outer_loop->pre,
&& seen_derived_types.contains (CLASS_DATA (c)->ts.u.derived));
bool inside_wrapper = generating_copy_helper;
- bool is_pdt_type = c->ts.type == BT_DERIVED
- && c->ts.u.derived->attr.pdt_type;
+ bool is_pdt_type = IS_PDT (c);
cdecl = c->backend_decl;
ctype = TREE_TYPE (cdecl);
cdecl, NULL_TREE);
dcmp = fold_convert (TREE_TYPE (comp), dcmp);
- if (c->ts.type == BT_DERIVED && c->ts.u.derived->attr.pdt_type
- && !c->attr.allocatable)
+ if (IS_PDT (c) && !c->attr.allocatable)
{
tmp = gfc_copy_alloc_comp (c->ts.u.derived, comp, dcmp,
0, 0);
}
}
else if (c->initializer && !c->attr.pdt_string && !c->attr.pdt_array
- && !c->as && !(c->ts.type == BT_DERIVED
- && c->ts.u.derived->attr.pdt_type)) /* Take care of arrays. */
+ && !c->as && !IS_PDT (c)) /* Take care of arrays. */
{
gfc_se tse;
gfc_expr *c_expr;
/* Allocate parameterized arrays of parameterized derived types. */
if (!(c->attr.pdt_array && c->as && c->as->type == AS_EXPLICIT)
- && !((c->ts.type == BT_DERIVED || c->ts.type == BT_CLASS)
- && (c->ts.u.derived && c->ts.u.derived->attr.pdt_type)))
+ && !(IS_PDT (c) || IS_CLASS_PDT (c)))
continue;
if (c->ts.type == BT_CLASS)
}
/* Recurse in to PDT components. */
- if ((c->ts.type == BT_DERIVED || c->ts.type == BT_CLASS)
- && c->ts.u.derived && c->ts.u.derived->attr.pdt_type
+ if ((IS_PDT (c) || IS_CLASS_PDT (c))
&& !(c->attr.pointer || c->attr.allocatable))
{
gfc_actual_arglist *tail = c->param_list;
of parameterized derived types. */
if (!(c->attr.pdt_array && c->as && c->as->type == AS_EXPLICIT)
&& !c->attr.pdt_string
- && !((c->ts.type == BT_DERIVED || c->ts.type == BT_CLASS)
- && (c->ts.u.derived && c->ts.u.derived->attr.pdt_type)))
+ && !(IS_PDT (c) || IS_CLASS_PDT (c)))
continue;
comp = fold_build3_loc (input_location, COMPONENT_REF, ctype,
comp = gfc_class_data_get (comp);
/* Recurse in to PDT components. */
- if ((c->ts.type == BT_DERIVED || c->ts.type == BT_CLASS)
- && c->ts.u.derived && c->ts.u.derived->attr.pdt_type
+ if ((IS_PDT (c) || IS_CLASS_PDT (c))
&& (!c->attr.pointer && !c->attr.allocatable))
{
tmp = gfc_deallocate_pdt_comp (c->ts.u.derived, comp,
for (gfc_component *c = der_type->components; c; c = c->next)
if (c->attr.pdt_array || c->attr.pdt_string)
parameterized_comps = true;
- else if (c->ts.type == BT_DERIVED
- && c->ts.u.derived->attr.pdt_type
- && strcmp (der_type->name, c->ts.u.derived->name))
+ else if (IS_PDT (c) && strcmp (der_type->name, c->ts.u.derived->name))
parameterized_comps = has_parameterized_comps (c->ts.u.derived);
return parameterized_comps;
}
|| sym->attr.data || sym->ns->proc_name->attr.flavor == FL_MODULE)
&& (flag_coarray != GFC_FCOARRAY_LIB
|| !sym->attr.codimension || sym->attr.allocatable)
- && !(sym->ts.type == BT_DERIVED && sym->ts.u.derived->attr.pdt_type)
- && !(sym->ts.type == BT_CLASS
- && CLASS_DATA (sym)->ts.u.derived->attr.pdt_type))
+ && !(IS_PDT (sym) || IS_CLASS_PDT (sym)))
{
/* Add static initializer. For procedures, it is only needed if
SAVE is specified otherwise they need to be reinitialized
gcc_assert (block);
/* Initialization of PDTs is done elsewhere. */
- if (sym->ts.type == BT_DERIVED && sym->ts.u.derived->attr.pdt_type
- && !pdt_ok)
+ if (IS_PDT (sym) && !pdt_ok)
return;
gcc_assert (!sym->attr.allocatable);
&& proc_sym != proc_sym->result) ? proc_sym->result : NULL;
if (sym && !sym->attr.allocatable && !sym->attr.pointer
- && sym->ts.type == BT_DERIVED
- && sym->ts.u.derived
- && !gfc_has_default_initializer (sym->ts.u.derived)
- && sym->ts.u.derived->attr.pdt_type)
+ && IS_PDT (sym) && !gfc_has_default_initializer (sym->ts.u.derived))
{
gfc_init_block (&tmpblock);
tmp = gfc_allocate_pdt_comp (sym->ts.u.derived,
gfc_add_init_cleanup (block, gfc_finish_block (&tmpblock), NULL);
}
}
- else if (sym->ts.type == BT_CLASS
- && CLASS_DATA (sym)->ts.u.derived
- && CLASS_DATA (sym)->ts.u.derived->attr.pdt_type)
+ else if (IS_CLASS_PDT (sym))
{
gfc_component *data = CLASS_DATA (sym);
is_pdt_type = true;
/* This permits the return value to be correctly initialized, even when the
function result was not referenced. */
if (sym->abr_modproc_decl
- && sym->ts.type == BT_DERIVED
- && sym->ts.u.derived->attr.pdt_type
+ && IS_PDT (sym)
&& !sym->attr.allocatable
&& sym->result == sym
&& get_proc_result (sym) == NULL_TREE)
gcc_assert (fsym && fsym->attr.value && !fsym->attr.dimension);
- if (e && e->ts.type == BT_DERIVED && e->ts.u.derived->attr.pdt_type)
+ if (IS_PDT (e))
{
tmp = gfc_create_var (TREE_TYPE (parmse->expr), "PDT");
gfc_add_modify (&parmse->pre, tmp, parmse->expr);
if (!init)
{
- if (expr->ts.type == BT_DERIVED && expr->ts.u.derived->attr.pdt_type
- && expr->must_finalize)
+ if (IS_PDT (expr) && expr->must_finalize)
final_block = &se->finalblock;
/* Create a temporary variable and fill it in. */
if (dealloc
&& !expr1->symtree->n.sym->attr.associate_var
&& expr2->expr_type != EXPR_ARRAY
- && ((expr1->ts.type == BT_DERIVED
- && expr1->ts.u.derived
- && expr1->ts.u.derived->attr.pdt_type)
- || (expr1->ts.type == BT_CLASS
- && CLASS_DATA (expr1)->ts.u.derived
- && CLASS_DATA (expr1)->ts.u.derived->attr.pdt_type)))
+ && (IS_PDT (expr1) || IS_CLASS_PDT (expr1)))
{
bool pdt_dep = gfc_check_dependency (expr1, expr2, true);
/* Since parameterized components cannot have default initializers,
the default PDT constructor leaves them unallocated. Do the
allocation now. */
- if (init_flag && expr1->ts.type == BT_DERIVED
- && expr1->ts.u.derived->attr.pdt_type
+ if (init_flag && IS_PDT (expr1)
&& !expr1->symtree->n.sym->attr.allocatable
&& !expr1->symtree->n.sym->attr.dummy)
{
dim, gfc_index_one_node);
}
- if (e->expr_type == EXPR_FUNCTION
- && sym->ts.type == BT_DERIVED
- && sym->ts.u.derived
- && sym->ts.u.derived->attr.pdt_type)
+ if (e->expr_type == EXPR_FUNCTION && IS_PDT (e))
{
tmp = gfc_deallocate_pdt_comp (sym->ts.u.derived, se.expr,
sym->as->rank);
}
tmp = sym->backend_decl;
- if (e->expr_type == EXPR_FUNCTION
- && sym->ts.type == BT_DERIVED
- && sym->ts.u.derived
- && sym->ts.u.derived->attr.pdt_type)
+ if (e->expr_type == EXPR_FUNCTION && IS_PDT (sym))
{
tmp = gfc_deallocate_pdt_comp (sym->ts.u.derived, tmp,
0);
}
- else if (e->expr_type == EXPR_FUNCTION
- && sym->ts.type == BT_CLASS
- && CLASS_DATA (sym)->ts.u.derived
- && CLASS_DATA (sym)->ts.u.derived->attr.pdt_type)
+ else if (e->expr_type == EXPR_FUNCTION && IS_CLASS_PDT (sym))
{
tmp = gfc_class_data_get (tmp);
tmp = gfc_deallocate_pdt_comp (CLASS_DATA (sym)->ts.u.derived,
}
/* Set KIND and LEN PDT components and allocate those that are
parameterized. */
- else if (expr->ts.type == BT_DERIVED
- && expr->ts.u.derived->attr.pdt_type)
+ else if (IS_PDT (expr))
{
if (code->expr3 && code->expr3->param_list)
param_list = code->expr3->param_list;
gfc_add_expr_to_block (&block, tmp);
}
/* Ditto for CLASS expressions. */
- else if (expr->ts.type == BT_CLASS
- && CLASS_DATA (expr)->ts.u.derived->attr.pdt_type)
+ else if (IS_CLASS_PDT (expr))
{
if (code->expr3 && code->expr3->param_list)
param_list = code->expr3->param_list;
param_list = expr->symtree->n.sym->param_list;
for (ref = expr->ref; ref; ref = ref->next)
if (ref->type == REF_COMPONENT
- && ref->u.c.component->ts.type == BT_DERIVED
- && ref->u.c.component->ts.u.derived->attr.pdt_type
+ && IS_PDT (ref->u.c.component)
&& ref->u.c.component->param_list)
param_list = ref->u.c.component->param_list;
if (expr->ts.type == BT_DERIVED
&& ((expr->ts.u.derived->attr.pdt_type && param_list)
|| expr->ts.u.derived->attr.pdt_comp))
tmp = gfc_deallocate_pdt_comp (expr->ts.u.derived, se.expr, expr->rank);
- else if (expr->ts.type == BT_CLASS
- && CLASS_DATA (expr)->ts.u.derived->attr.pdt_type
- && expr->symtree->n.sym->param_list)
+ else if (IS_CLASS_PDT (expr) && expr->symtree->n.sym->param_list)
tmp = gfc_deallocate_pdt_comp (CLASS_DATA (expr)->ts.u.derived,
se.expr, expr->rank);