+2016-10-24 Jakub Jelinek <jakub@redhat.com>
+
+ * trans-intrinsic.c (gfc_conv_intrinsic_minmax): Use VAR_P (x)
+ instead of TREE_CODE (x) == VAR_DECL.
+ * trans-expr.c (gfc_class_vptr_get, gfc_class_len_get,
+ gfc_class_len_or_zero_get, gfc_get_vptr_from_expr,
+ gfc_conv_string_length, conv_base_obj_fcn_val,
+ gfc_conv_procedure_call, gfc_trans_assignment_1): Likewise.
+ * trans-openmp.c (gfc_omp_predetermined_sharing,
+ gfc_omp_disregard_value_expr, gfc_omp_private_debug_clause,
+ gfc_trans_omp_atomic, gfc_trans_omp_do): Likewise.
+ * trans-io.c (nml_get_addr_expr): Likewise.
+ * trans-decl.c (gfc_finish_decl, gfc_build_qualified_array,
+ gfc_get_symbol_decl, gfc_get_fake_result_decl,
+ gfc_trans_deferred_vars, gfc_trans_use_stmts,
+ generate_local_decl): Likewise.
+ * trans-array.c (trans_array_constructor, trans_array_bound_check,
+ build_class_array_ref, gfc_array_init_size,
+ gfc_trans_auto_array_allocation, gfc_trans_g77_array,
+ gfc_trans_dummy_array_bias, gfc_alloc_allocatable_for_assignment,
+ gfc_trans_deferred_array): Likewise.
+ * trans.c (gfc_build_array_ref): Likewise. Use
+ VAR_OR_FUNCTION_DECL_P (x) instead of TREE_CODE (x) == VAR_DECL
+ || TREE_CODE (x) == FUNCTION_DECL.
+
2016-10-23 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/77763
offsetvar, gfc_index_one_node);
tmp = gfc_evaluate_now (tmp, &outer_loop->pre);
gfc_conv_descriptor_ubound_set (&loop->pre, desc, gfc_rank_cst[0], tmp);
- if (*loop_ubound0 && TREE_CODE (*loop_ubound0) == VAR_DECL)
+ if (*loop_ubound0 && VAR_P (*loop_ubound0))
gfc_add_modify (&outer_loop->pre, *loop_ubound0, tmp);
else
*loop_ubound0 = tmp;
name = ss->info->expr->symtree->n.sym->name;
gcc_assert (name != NULL);
- if (TREE_CODE (descriptor) == VAR_DECL)
+ if (VAR_P (descriptor))
name = IDENTIFIER_POINTER (DECL_NAME (descriptor));
/* If upper bound is present, include both bounds in the error message. */
else
type = NULL_TREE;
}
- if (TREE_CODE (tmp) == VAR_DECL)
+ if (VAR_P (tmp))
break;
}
/* Set the dtype before the alloc, because registration of coarrays needs
it initialized. */
- if (expr->ts.type == BT_CHARACTER && expr->ts.deferred
- && TREE_CODE (expr->ts.u.cl->backend_decl) == VAR_DECL)
+ if (expr->ts.type == BT_CHARACTER
+ && expr->ts.deferred
+ && VAR_P (expr->ts.u.cl->backend_decl))
{
type = gfc_typenode_for_spec (&expr->ts);
tmp = gfc_conv_descriptor_dtype (descriptor);
/* Don't actually allocate space for Cray Pointees. */
if (sym->attr.cray_pointee)
{
- if (TREE_CODE (GFC_TYPE_ARRAY_OFFSET (type)) == VAR_DECL)
+ if (VAR_P (GFC_TYPE_ARRAY_OFFSET (type)))
gfc_add_modify (&init, GFC_TYPE_ARRAY_OFFSET (type), offset);
gfc_add_init_cleanup (block, gfc_finish_block (&init), NULL_TREE);
}
/* Set offset of the array. */
- if (TREE_CODE (GFC_TYPE_ARRAY_OFFSET (type)) == VAR_DECL)
+ if (VAR_P (GFC_TYPE_ARRAY_OFFSET (type)))
gfc_add_modify (&init, GFC_TYPE_ARRAY_OFFSET (type), offset);
/* Automatic arrays should not have initializers. */
gfc_start_block (&init);
if (sym->ts.type == BT_CHARACTER
- && TREE_CODE (sym->ts.u.cl->backend_decl) == VAR_DECL)
+ && VAR_P (sym->ts.u.cl->backend_decl))
gfc_conv_string_length (sym->ts.u.cl, NULL, &init);
/* Evaluate the bounds of the array. */
gfc_trans_array_bounds (type, sym, &offset, &init);
/* Set the offset. */
- if (TREE_CODE (GFC_TYPE_ARRAY_OFFSET (type)) == VAR_DECL)
+ if (VAR_P (GFC_TYPE_ARRAY_OFFSET (type)))
gfc_add_modify (&init, GFC_TYPE_ARRAY_OFFSET (type), offset);
/* Set the pointer itself if we aren't using the parameter directly. */
gfc_start_block (&init);
if (sym->ts.type == BT_CHARACTER
- && TREE_CODE (sym->ts.u.cl->backend_decl) == VAR_DECL)
+ && VAR_P (sym->ts.u.cl->backend_decl))
gfc_conv_string_length (sym->ts.u.cl, NULL, &init);
checkparm = (as->type == AS_EXPLICIT
gfc_trans_array_cobounds (type, &init, sym);
/* Set the offset. */
- if (TREE_CODE (GFC_TYPE_ARRAY_OFFSET (type)) == VAR_DECL)
+ if (VAR_P (GFC_TYPE_ARRAY_OFFSET (type)))
gfc_add_modify (&init, GFC_TYPE_ARRAY_OFFSET (type), offset);
gfc_trans_vla_type_sizes (sym, &init);
tmp = gfc_conv_descriptor_offset (desc);
gfc_add_modify (&fblock, tmp, offset);
if (linfo->saved_offset
- && TREE_CODE (linfo->saved_offset) == VAR_DECL)
+ && VAR_P (linfo->saved_offset))
gfc_add_modify (&fblock, linfo->saved_offset, tmp);
/* Now set the deltas for the lhs. */
tmp = fold_build2_loc (input_location, MINUS_EXPR,
gfc_array_index_type, tmp,
loop->from[dim]);
- if (linfo->delta[dim]
- && TREE_CODE (linfo->delta[dim]) == VAR_DECL)
+ if (linfo->delta[dim] && VAR_P (linfo->delta[dim]))
gfc_add_modify (&fblock, linfo->delta[dim], tmp);
}
{
if (expr2->ts.deferred)
{
- if (TREE_CODE (expr2->ts.u.cl->backend_decl) == VAR_DECL)
+ if (VAR_P (expr2->ts.u.cl->backend_decl))
tmp = expr2->ts.u.cl->backend_decl;
else
tmp = rss->info->string_length;
}
if (expr1->ts.u.cl->backend_decl
- && TREE_CODE (expr1->ts.u.cl->backend_decl) == VAR_DECL)
+ && VAR_P (expr1->ts.u.cl->backend_decl))
gfc_add_modify (&fblock, expr1->ts.u.cl->backend_decl, tmp);
else
gfc_add_modify (&fblock, lss->info->string_length, tmp);
gfc_add_expr_to_block (&fblock, tmp);
/* Make sure that the scalarizer data pointer is updated. */
- if (linfo->data
- && TREE_CODE (linfo->data) == VAR_DECL)
+ if (linfo->data && VAR_P (linfo->data))
{
tmp = gfc_conv_descriptor_data_get (desc);
gfc_add_modify (&fblock, linfo->data, tmp);
gfc_set_backend_locus (&sym->declared_at);
gfc_init_block (&init);
- gcc_assert (TREE_CODE (sym->backend_decl) == VAR_DECL
- || TREE_CODE (sym->backend_decl) == PARM_DECL);
+ gcc_assert (VAR_P (sym->backend_decl)
+ || TREE_CODE (sym->backend_decl) == PARM_DECL);
if (sym->ts.type == BT_CHARACTER
&& !INTEGER_CST_P (sym->ts.u.cl->backend_decl))
gcc_assert (TREE_CODE (decl) == PARM_DECL
|| DECL_INITIAL (decl) == NULL_TREE);
- if (TREE_CODE (decl) != VAR_DECL)
+ if (!VAR_P (decl))
return;
if (DECL_SIZE (decl) == NULL_TREE
if (TYPE_NAME (type) != NULL_TREE
&& GFC_TYPE_ARRAY_UBOUND (type, as->rank - 1) != NULL_TREE
- && TREE_CODE (GFC_TYPE_ARRAY_UBOUND (type, as->rank - 1)) == VAR_DECL)
+ && VAR_P (GFC_TYPE_ARRAY_UBOUND (type, as->rank - 1)))
{
tree gtype = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
can be tracked by VTA. Also set DECL_NAMELESS, so that
the artificial lbound.N or ubound.N DECL_NAME doesn't
end up in debug info. */
- if (lbound && TREE_CODE (lbound) == VAR_DECL
- && DECL_ARTIFICIAL (lbound) && DECL_IGNORED_P (lbound))
+ if (lbound
+ && VAR_P (lbound)
+ && DECL_ARTIFICIAL (lbound)
+ && DECL_IGNORED_P (lbound))
{
if (DECL_NAME (lbound)
&& strstr (IDENTIFIER_POINTER (DECL_NAME (lbound)),
DECL_NAMELESS (lbound) = 1;
DECL_IGNORED_P (lbound) = 0;
}
- if (ubound && TREE_CODE (ubound) == VAR_DECL
- && DECL_ARTIFICIAL (ubound) && DECL_IGNORED_P (ubound))
+ if (ubound
+ && VAR_P (ubound)
+ && DECL_ARTIFICIAL (ubound)
+ && DECL_IGNORED_P (ubound))
{
if (DECL_NAME (ubound)
&& strstr (IDENTIFIER_POINTER (DECL_NAME (ubound)),
length = gfc_create_string_length (sym);
else
length = sym->ts.u.cl->backend_decl;
- if (TREE_CODE (length) == VAR_DECL
- && DECL_FILE_SCOPE_P (length))
+ if (VAR_P (length) && DECL_FILE_SCOPE_P (length))
{
/* Add the string length to the same context as the symbol. */
if (DECL_CONTEXT (sym->backend_decl) == current_function_decl)
{
if (sym->attr.associate_var
&& sym->ts.u.cl->backend_decl
- && TREE_CODE (sym->ts.u.cl->backend_decl) == VAR_DECL)
+ && VAR_P (sym->ts.u.cl->backend_decl))
length = gfc_index_zero_node;
else
length = gfc_create_string_length (sym);
length = gfc_create_string_length (sym);
else
length = sym->ts.u.cl->backend_decl;
- if (TREE_CODE (length) == VAR_DECL
- && DECL_CONTEXT (length) == NULL_TREE)
+ if (VAR_P (length) && DECL_CONTEXT (length) == NULL_TREE)
gfc_add_decl_to_function (length);
}
/* An automatic character length, pointer array result. */
if (proc_sym->ts.type == BT_CHARACTER
- && TREE_CODE (proc_sym->ts.u.cl->backend_decl) == VAR_DECL)
+ && VAR_P (proc_sym->ts.u.cl->backend_decl))
{
tmp = NULL;
if (proc_sym->ts.deferred)
gfc_add_init_cleanup (block, gfc_finish_block (&init), tmp);
}
- else if (TREE_CODE (proc_sym->ts.u.cl->backend_decl) == VAR_DECL)
+ else if (VAR_P (proc_sym->ts.u.cl->backend_decl))
gfc_trans_dummy_character (proc_sym, proc_sym->ts.u.cl, block);
}
else
&& strcmp (st->n.sym->module, use_stmt->module_name) == 0)
{
gcc_assert (DECL_EXTERNAL (entry->namespace_decl)
- || (TREE_CODE (st->n.sym->backend_decl)
- != VAR_DECL));
+ || !VAR_P (st->n.sym->backend_decl));
decl = copy_node (st->n.sym->backend_decl);
DECL_CONTEXT (decl) = entry->namespace_decl;
DECL_EXTERNAL (decl) = 1;
if (sym->attr.dummy && !sym->attr.referenced
&& sym->ts.type == BT_CHARACTER
&& sym->ts.u.cl->backend_decl != NULL
- && TREE_CODE (sym->ts.u.cl->backend_decl) == VAR_DECL)
+ && VAR_P (sym->ts.u.cl->backend_decl))
{
sym->attr.referenced = 1;
gfc_get_symbol_decl (sym);
tree vptr;
/* For class arrays decl may be a temporary descriptor handle, the vptr is
then available through the saved descriptor. */
- if (TREE_CODE (decl) == VAR_DECL && DECL_LANG_SPECIFIC (decl)
+ if (VAR_P (decl) && DECL_LANG_SPECIFIC (decl)
&& GFC_DECL_SAVED_DESCRIPTOR (decl))
decl = GFC_DECL_SAVED_DESCRIPTOR (decl);
if (POINTER_TYPE_P (TREE_TYPE (decl)))
tree len;
/* For class arrays decl may be a temporary descriptor handle, the len is
then available through the saved descriptor. */
- if (TREE_CODE (decl) == VAR_DECL && DECL_LANG_SPECIFIC (decl)
+ if (VAR_P (decl) && DECL_LANG_SPECIFIC (decl)
&& GFC_DECL_SAVED_DESCRIPTOR (decl))
decl = GFC_DECL_SAVED_DESCRIPTOR (decl);
if (POINTER_TYPE_P (TREE_TYPE (decl)))
tree len;
/* For class arrays decl may be a temporary descriptor handle, the vptr is
then available through the saved descriptor. */
- if (TREE_CODE (decl) == VAR_DECL && DECL_LANG_SPECIFIC (decl)
+ if (VAR_P (decl) && DECL_LANG_SPECIFIC (decl)
&& GFC_DECL_SAVED_DESCRIPTOR (decl))
decl = GFC_DECL_SAVED_DESCRIPTOR (decl);
if (POINTER_TYPE_P (TREE_TYPE (decl)))
else
type = NULL_TREE;
}
- if (TREE_CODE (tmp) == VAR_DECL
- || TREE_CODE (tmp) == PARM_DECL)
+ if (VAR_P (tmp) || TREE_CODE (tmp) == PARM_DECL)
break;
}
gfc_init_se (&se, NULL);
- if (!cl->length
- && cl->backend_decl
- && TREE_CODE (cl->backend_decl) == VAR_DECL)
+ if (!cl->length && cl->backend_decl && VAR_P (cl->backend_decl))
return;
/* If cl->length is NULL, use gfc_conv_expr to obtain the string length but
gfc_ref *ref;
tree var;
- if (TREE_CODE (base_object) != VAR_DECL)
+ if (!VAR_P (base_object))
{
var = gfc_create_var (TREE_TYPE (base_object), NULL);
gfc_add_modify (&se->pre, var, base_object);
else
{
tmp = parmse.string_length;
- if (TREE_CODE (tmp) != VAR_DECL
- && TREE_CODE (tmp) != COMPONENT_REF)
+ if (!VAR_P (tmp) && TREE_CODE (tmp) != COMPONENT_REF)
tmp = gfc_evaluate_now (parmse.string_length, &se->pre);
parmse.string_length = gfc_build_addr_expr (NULL_TREE, tmp);
}
if (ts.type == BT_CHARACTER && ts.deferred)
{
tmp = len;
- if (TREE_CODE (tmp) != VAR_DECL)
+ if (!VAR_P (tmp))
tmp = gfc_evaluate_now (len, &se->pre);
TREE_STATIC (tmp) = 1;
gfc_add_modify (&se->pre, tmp,
/* Stabilize a string length for temporaries. */
if (expr2->ts.type == BT_CHARACTER && !expr1->ts.deferred
- && !(TREE_CODE (rse.string_length) == VAR_DECL
+ && !(VAR_P (rse.string_length)
|| TREE_CODE (rse.string_length) == PARM_DECL
|| TREE_CODE (rse.string_length) == INDIRECT_REF))
string_length = gfc_evaluate_now (rse.string_length, &rse.pre);
if (TREE_TYPE (args[0]) != type)
args[0] = convert (type, args[0]);
/* Only evaluate the argument once. */
- if (TREE_CODE (args[0]) != VAR_DECL && !TREE_CONSTANT (args[0]))
+ if (!VAR_P (args[0]) && !TREE_CONSTANT (args[0]))
args[0] = gfc_evaluate_now (args[0], &se->pre);
mvar = gfc_create_var (type, "M");
cond = NULL_TREE;
/* Only evaluate the argument once. */
- if (TREE_CODE (val) != VAR_DECL && !TREE_CONSTANT (val))
+ if (!VAR_P (val) && !TREE_CONSTANT (val))
val = gfc_evaluate_now (val, &se->pre);
}
else
decl = c->backend_decl;
- gcc_assert (decl && ((TREE_CODE (decl) == FIELD_DECL
- || TREE_CODE (decl) == VAR_DECL
- || TREE_CODE (decl) == PARM_DECL)
- || TREE_CODE (decl) == COMPONENT_REF));
+ gcc_assert (decl && (TREE_CODE (decl) == FIELD_DECL
+ || VAR_P (decl)
+ || TREE_CODE (decl) == PARM_DECL
+ || TREE_CODE (decl) == COMPONENT_REF));
tmp = decl;
variables at all (they can't be redefined), but they can nevertheless appear
in parallel/task regions and for default(none) purposes treat them as shared.
For vtables likely the same handling is desirable. */
- if (TREE_CODE (decl) == VAR_DECL
- && TREE_READONLY (decl)
- && TREE_STATIC (decl))
+ if (VAR_P (decl) && TREE_READONLY (decl) && TREE_STATIC (decl))
return OMP_CLAUSE_DEFAULT_SHARED;
return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
tree value = DECL_VALUE_EXPR (decl);
if (TREE_CODE (value) == COMPONENT_REF
- && TREE_CODE (TREE_OPERAND (value, 0)) == VAR_DECL
+ && VAR_P (TREE_OPERAND (value, 0))
&& GFC_DECL_COMMON_OR_EQUIV (TREE_OPERAND (value, 0)))
{
/* If variable in COMMON or EQUIVALENCE is privatized, return
tree value = DECL_VALUE_EXPR (decl);
if (TREE_CODE (value) == COMPONENT_REF
- && TREE_CODE (TREE_OPERAND (value, 0)) == VAR_DECL
+ && VAR_P (TREE_OPERAND (value, 0))
&& GFC_DECL_COMMON_OR_EQUIV (TREE_OPERAND (value, 0)))
return shared;
}
lhsaddr = save_expr (lhsaddr);
if (TREE_CODE (lhsaddr) != SAVE_EXPR
&& (TREE_CODE (lhsaddr) != ADDR_EXPR
- || TREE_CODE (TREE_OPERAND (lhsaddr, 0)) != VAR_DECL))
+ || !VAR_P (TREE_OPERAND (lhsaddr, 0))))
{
/* Make sure LHS is simple enough so that goa_lhs_expr_p can recognize
it even after unsharing function body. */
dovar_decl = dovar;
/* Special case simple loops. */
- if (TREE_CODE (dovar) == VAR_DECL)
+ if (VAR_P (dovar))
{
if (integer_onep (step))
simple = 1;
references. */
if (type && TREE_CODE (type) == ARRAY_TYPE
&& TYPE_MAXVAL (TYPE_DOMAIN (type)) != NULL_TREE
- && (TREE_CODE (TYPE_MAXVAL (TYPE_DOMAIN (type))) == VAR_DECL
+ && (VAR_P (TYPE_MAXVAL (TYPE_DOMAIN (type)))
|| TREE_CODE (TYPE_MAXVAL (TYPE_DOMAIN (type))) == INDIRECT_REF)
&& decl
&& (TREE_CODE (TYPE_MAXVAL (TYPE_DOMAIN (type))) == INDIRECT_REF
subreference, use the span that is stored with the backend decl
and reference the element with pointer arithmetic. */
if ((decl && (TREE_CODE (decl) == FIELD_DECL
- || TREE_CODE (decl) == VAR_DECL
- || TREE_CODE (decl) == PARM_DECL
- || TREE_CODE (decl) == FUNCTION_DECL)
+ || VAR_OR_FUNCTION_DECL_P (decl)
+ || TREE_CODE (decl) == PARM_DECL)
&& ((GFC_DECL_SUBREF_ARRAY_P (decl)
&& !integer_zerop (GFC_DECL_SPAN (decl)))
|| GFC_DECL_CLASS (decl)