diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ef49d6f09ef..5c47028555b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,28 @@ +2016-10-24 Jakub Jelinek + + * 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 PR fortran/77763 diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index c59e8727f3d..117349e0c63 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -2373,7 +2373,7 @@ trans_array_constructor (gfc_ss * ss, locus * where) 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; @@ -2860,7 +2860,7 @@ trans_array_bound_check (gfc_se * se, gfc_ss *ss, tree index, int n, 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. */ @@ -3104,7 +3104,7 @@ build_class_array_ref (gfc_se *se, tree base, tree index) else type = NULL_TREE; } - if (TREE_CODE (tmp) == VAR_DECL) + if (VAR_P (tmp)) break; } @@ -5096,8 +5096,9 @@ gfc_array_init_size (tree descriptor, int rank, int corank, tree * poffset, /* 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); @@ -5968,7 +5969,7 @@ gfc_trans_auto_array_allocation (tree decl, gfc_symbol * sym, /* 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); @@ -6001,7 +6002,7 @@ gfc_trans_auto_array_allocation (tree decl, gfc_symbol * sym, } /* 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. */ @@ -6054,14 +6055,14 @@ gfc_trans_g77_array (gfc_symbol * sym, gfc_wrapped_block * block) 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. */ @@ -6160,7 +6161,7 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, 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 @@ -6384,7 +6385,7 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, 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); @@ -8977,7 +8978,7 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop, 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. */ @@ -8988,8 +8989,7 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop, 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); } @@ -8998,7 +8998,7 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop, { 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; @@ -9016,7 +9016,7 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop, } 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); @@ -9182,8 +9182,7 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop, 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); @@ -9227,8 +9226,8 @@ gfc_trans_deferred_array (gfc_symbol * sym, gfc_wrapped_block * block) 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)) diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 407c4a1fdbc..4f8ef17dda6 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -495,7 +495,7 @@ gfc_finish_decl (tree 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 @@ -1020,7 +1020,7 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym) 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)); @@ -1050,8 +1050,10 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym) 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)), @@ -1059,8 +1061,10 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym) 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)), @@ -1514,8 +1518,7 @@ gfc_get_symbol_decl (gfc_symbol * sym) 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) @@ -1630,7 +1633,7 @@ gfc_get_symbol_decl (gfc_symbol * sym) { 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); @@ -2924,8 +2927,7 @@ gfc_get_fake_result_decl (gfc_symbol * sym, int parent_flag) 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); } @@ -4123,7 +4125,7 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block) /* 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) @@ -4176,7 +4178,7 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block) 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 @@ -4843,8 +4845,7 @@ gfc_trans_use_stmts (gfc_namespace * ns) && 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; @@ -5385,7 +5386,7 @@ generate_local_decl (gfc_symbol * sym) 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); diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index fc03a23d9ed..525bb67e73a 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -198,7 +198,7 @@ gfc_class_vptr_get (tree decl) 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))) @@ -217,7 +217,7 @@ gfc_class_len_get (tree 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))) @@ -239,7 +239,7 @@ gfc_class_len_or_zero_get (tree 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))) @@ -485,8 +485,7 @@ gfc_get_vptr_from_expr (tree expr) 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; } @@ -2160,9 +2159,7 @@ gfc_conv_string_length (gfc_charlen * cl, gfc_expr * expr, stmtblock_t * pblock) 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 @@ -3664,7 +3661,7 @@ conv_base_obj_fcn_val (gfc_se * se, tree base_object, gfc_expr * expr) 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); @@ -5675,8 +5672,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, 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); } @@ -6019,7 +6015,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, 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, @@ -9692,7 +9688,7 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag, /* 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); diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index a9825ea7c49..2911d642e32 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -3653,7 +3653,7 @@ gfc_conv_intrinsic_minmax (gfc_se * se, gfc_expr * expr, enum tree_code op) 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"); @@ -3677,7 +3677,7 @@ gfc_conv_intrinsic_minmax (gfc_se * se, gfc_expr * expr, enum tree_code op) 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); } diff --git a/gcc/fortran/trans-io.c b/gcc/fortran/trans-io.c index 216317ad3d3..a355ee22df9 100644 --- a/gcc/fortran/trans-io.c +++ b/gcc/fortran/trans-io.c @@ -1573,10 +1573,10 @@ nml_get_addr_expr (gfc_symbol * sym, gfc_component * c, 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; diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index b8b8576f366..febff255438 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -143,9 +143,7 @@ gfc_omp_predetermined_sharing (tree 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; @@ -1156,7 +1154,7 @@ gfc_omp_disregard_value_expr (tree decl, bool shared) 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 @@ -1192,7 +1190,7 @@ gfc_omp_private_debug_clause (tree decl, bool shared) 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; } @@ -3001,7 +2999,7 @@ gfc_trans_omp_atomic (gfc_code *code) 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. */ @@ -3233,7 +3231,7 @@ gfc_trans_omp_do (gfc_code *code, gfc_exec_op op, stmtblock_t *pblock, dovar_decl = dovar; /* Special case simple loops. */ - if (TREE_CODE (dovar) == VAR_DECL) + if (VAR_P (dovar)) { if (integer_onep (step)) simple = 1; diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c index df77fc9b540..dc2f068768f 100644 --- a/gcc/fortran/trans.c +++ b/gcc/fortran/trans.c @@ -335,7 +335,7 @@ gfc_build_array_ref (tree base, tree offset, tree decl, tree vptr) 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 @@ -356,9 +356,8 @@ gfc_build_array_ref (tree base, tree offset, tree decl, tree vptr) 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)