diff options
Diffstat (limited to 'gcc/fortran/trans-expr.c')
-rw-r--r-- | gcc/fortran/trans-expr.c | 125 |
1 files changed, 58 insertions, 67 deletions
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 94653c9..52d6969 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -34,7 +34,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "tree-gimple.h" #include "flags.h" #include <gmp.h> -#include <assert.h> #include "gfortran.h" #include "trans.h" #include "trans-const.h" @@ -84,14 +83,14 @@ gfc_advance_se_ss_chain (gfc_se * se) { gfc_se *p; - assert (se != NULL && se->ss != NULL && se->ss != gfc_ss_terminator); + gcc_assert (se != NULL && se->ss != NULL && se->ss != gfc_ss_terminator); p = se; /* Walk down the parent chain. */ while (p != NULL) { /* Simple consistency check. */ - assert (p->parent == NULL || p->parent->ss == p->ss); + gcc_assert (p->parent == NULL || p->parent->ss == p->ss); p->ss = p->ss->next; @@ -125,14 +124,14 @@ gfc_conv_expr_present (gfc_symbol * sym) { tree decl; - assert (sym->attr.dummy && sym->attr.optional); + gcc_assert (sym->attr.dummy && sym->attr.optional); decl = gfc_get_symbol_decl (sym); if (TREE_CODE (decl) != PARM_DECL) { /* Array parameters use a temporary descriptor, we want the real parameter. */ - assert (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (decl)) + gcc_assert (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (decl)) || GFC_ARRAY_TYPE_P (TREE_TYPE (decl))); decl = GFC_DECL_SAVED_DESCRIPTOR (decl); } @@ -219,10 +218,10 @@ gfc_conv_component_ref (gfc_se * se, gfc_ref * ref) c = ref->u.c.component; - assert (c->backend_decl); + gcc_assert (c->backend_decl); field = c->backend_decl; - assert (TREE_CODE (field) == FIELD_DECL); + gcc_assert (TREE_CODE (field) == FIELD_DECL); decl = se->expr; tmp = build3 (COMPONENT_REF, TREE_TYPE (field), decl, field, NULL_TREE); @@ -232,7 +231,7 @@ gfc_conv_component_ref (gfc_se * se, gfc_ref * ref) { tmp = c->ts.cl->backend_decl; /* Components must always be constant length. */ - assert (tmp && INTEGER_CST_P (tmp)); + gcc_assert (tmp && INTEGER_CST_P (tmp)); se->string_length = tmp; } @@ -254,8 +253,8 @@ gfc_conv_variable (gfc_se * se, gfc_expr * expr) if (se->ss != NULL) { /* Check that something hasn't gone horribly wrong. */ - assert (se->ss != gfc_ss_terminator); - assert (se->ss->expr == expr); + gcc_assert (se->ss != gfc_ss_terminator); + gcc_assert (se->ss->expr == expr); /* A scalarized term. We already know the descriptor. */ se->expr = se->ss->data.info.descriptor; @@ -270,10 +269,10 @@ gfc_conv_variable (gfc_se * se, gfc_expr * expr) if (sym->attr.flavor == FL_PROCEDURE && se->expr != current_function_decl) { - assert (se->want_pointer); + gcc_assert (se->want_pointer); if (!sym->attr.dummy) { - assert (TREE_CODE (se->expr) == FUNCTION_DECL); + gcc_assert (TREE_CODE (se->expr) == FUNCTION_DECL); se->expr = gfc_build_addr_expr (NULL, se->expr); } return; @@ -309,7 +308,7 @@ gfc_conv_variable (gfc_se * se, gfc_expr * expr) if (sym->ts.type == BT_CHARACTER) { se->string_length = sym->ts.cl->backend_decl; - assert (se->string_length); + gcc_assert (se->string_length); } while (ref) @@ -340,7 +339,7 @@ gfc_conv_variable (gfc_se * se, gfc_expr * expr) break; default: - abort (); + gcc_unreachable (); break; } ref = ref->next; @@ -367,7 +366,7 @@ gfc_conv_unary_op (enum tree_code code, gfc_se * se, gfc_expr * expr) gfc_se operand; tree type; - assert (expr->ts.type != BT_CHARACTER); + gcc_assert (expr->ts.type != BT_CHARACTER); /* Initialize the operand. */ gfc_init_se (&operand, se); gfc_conv_expr_val (&operand, expr->op1); @@ -597,7 +596,7 @@ gfc_conv_power_op (gfc_se * se, gfc_expr * expr) break; default: - abort(); + gcc_unreachable (); } switch (kind) { @@ -606,7 +605,7 @@ gfc_conv_power_op (gfc_se * se, gfc_expr * expr) if (expr->op1->ts.type == BT_INTEGER) lse.expr = convert (gfc_int4_type_node, lse.expr); else - abort (); + gcc_unreachable (); /* Fall through. */ case 4: @@ -618,7 +617,7 @@ gfc_conv_power_op (gfc_se * se, gfc_expr * expr) break; default: - abort(); + gcc_unreachable (); } switch (expr->op1->ts.type) @@ -636,7 +635,7 @@ gfc_conv_power_op (gfc_se * se, gfc_expr * expr) break; default: - abort (); + gcc_unreachable (); } break; @@ -650,7 +649,7 @@ gfc_conv_power_op (gfc_se * se, gfc_expr * expr) fndecl = built_in_decls[BUILT_IN_POW]; break; default: - abort (); + gcc_unreachable (); } break; @@ -664,12 +663,12 @@ gfc_conv_power_op (gfc_se * se, gfc_expr * expr) fndecl = gfor_fndecl_math_cpow; break; default: - abort (); + gcc_unreachable (); } break; default: - abort (); + gcc_unreachable (); break; } @@ -688,8 +687,7 @@ gfc_conv_string_tmp (gfc_se * se, tree type, tree len) tree tmp; tree args; - if (TREE_TYPE (len) != gfc_charlen_type_node) - abort (); + gcc_assert (TREE_TYPE (len) == gfc_charlen_type_node); if (gfc_can_put_var_on_stack (len)) { @@ -736,7 +734,7 @@ gfc_conv_concat_op (gfc_se * se, gfc_expr * expr) tree args; tree tmp; - assert (expr->op1->ts.type == BT_CHARACTER + gcc_assert (expr->op1->ts.type == BT_CHARACTER && expr->op2->ts.type == BT_CHARACTER); gfc_init_se (&lse, se); @@ -899,8 +897,7 @@ gfc_conv_expr_op (gfc_se * se, gfc_expr * expr) case INTRINSIC_USER: case INTRINSIC_ASSIGN: /* These should be converted into function calls by the frontend. */ - abort (); - return; + gcc_unreachable (); default: fatal_error ("Unknown intrinsic op"); @@ -908,7 +905,7 @@ gfc_conv_expr_op (gfc_se * se, gfc_expr * expr) } /* The only exception to this is **, which is handled separately anyway. */ - assert (expr->op1->ts.type == expr->op2->ts.type); + gcc_assert (expr->op1->ts.type == expr->op2->ts.type); if (checkstring && expr->op1->ts.type != BT_CHARACTER) checkstring = 0; @@ -967,7 +964,7 @@ gfc_conv_function_val (gfc_se * se, gfc_symbol * sym) if (sym->attr.dummy) { tmp = gfc_get_symbol_decl (sym); - assert (TREE_CODE (TREE_TYPE (tmp)) == POINTER_TYPE + gcc_assert (TREE_CODE (TREE_TYPE (tmp)) == POINTER_TYPE && TREE_CODE (TREE_TYPE (TREE_TYPE (tmp))) == FUNCTION_TYPE); se->expr = tmp; @@ -978,7 +975,7 @@ gfc_conv_function_val (gfc_se * se, gfc_symbol * sym) sym->backend_decl = gfc_get_extern_function_decl (sym); tmp = sym->backend_decl; - assert (TREE_CODE (tmp) == FUNCTION_DECL); + gcc_assert (TREE_CODE (tmp) == FUNCTION_DECL); se->expr = gfc_build_addr_expr (NULL, tmp); } } @@ -1013,12 +1010,12 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym, { if (!sym->attr.elemental) { - assert (se->ss->type == GFC_SS_FUNCTION); + gcc_assert (se->ss->type == GFC_SS_FUNCTION); if (se->ss->useflags) { - assert (gfc_return_by_reference (sym) + gcc_assert (gfc_return_by_reference (sym) && sym->result->attr.dimension); - assert (se->loop != NULL); + gcc_assert (se->loop != NULL); /* Access the previously obtained result. */ gfc_conv_tmp_array_ref (se); @@ -1038,7 +1035,7 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym, arglist = gfc_chainon_list (arglist, se->expr); else if (sym->result->attr.dimension) { - assert (se->loop && se->ss); + gcc_assert (se->loop && se->ss); /* Set the type of the array. */ tmp = gfc_typenode_for_spec (&sym->ts); info->dimen = se->loop->dimen; @@ -1057,7 +1054,7 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym, } else if (sym->ts.type == BT_CHARACTER) { - assert (sym->ts.cl && sym->ts.cl->length + gcc_assert (sym->ts.cl && sym->ts.cl->length && sym->ts.cl->length->expr_type == EXPR_CONSTANT); len = gfc_conv_mpz_to_tree (sym->ts.cl->length->value.integer, sym->ts.cl->length->ts.kind); @@ -1071,7 +1068,7 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym, convert (gfc_charlen_type_node, len)); } else /* TODO: derived type function return values. */ - abort (); + gcc_unreachable (); } formal = sym->formal; @@ -1214,7 +1211,7 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym, se->string_length = len; } else - abort (); + gcc_unreachable (); } } } @@ -1273,7 +1270,7 @@ gfc_conv_statement_function (gfc_se * se, gfc_expr * expr) { /* Each dummy shall be specified, explicitly or implicitly, to be scalar. */ - assert (fargs->sym->attr.dimension == 0); + gcc_assert (fargs->sym->attr.dimension == 0); fsym = fargs->sym; /* Create a temporary to hold the value. */ @@ -1285,7 +1282,7 @@ gfc_conv_statement_function (gfc_se * se, gfc_expr * expr) /* Copy string arguments. */ tree arglen; - assert (fsym->ts.cl && fsym->ts.cl->length + gcc_assert (fsym->ts.cl && fsym->ts.cl->length && fsym->ts.cl->length->expr_type == EXPR_CONSTANT); arglen = TYPE_MAX_VALUE (TYPE_DOMAIN (type)); @@ -1380,8 +1377,8 @@ gfc_conv_function_expr (gfc_se * se, gfc_expr * expr) static void gfc_conv_array_constructor_expr (gfc_se * se, gfc_expr * expr) { - assert (se->ss != NULL && se->ss != gfc_ss_terminator); - assert (se->ss->expr == expr && se->ss->type == GFC_SS_CONSTRUCTOR); + gcc_assert (se->ss != NULL && se->ss != gfc_ss_terminator); + gcc_assert (se->ss->expr == expr && se->ss->type == GFC_SS_CONSTRUCTOR); gfc_conv_tmp_array_ref (se); gfc_advance_se_ss_chain (se); @@ -1513,8 +1510,7 @@ gfc_trans_subarray_assign (tree dest, gfc_component * cm, gfc_expr * expr) tmp = gfc_trans_scalar_assign (&lse, &rse, cm->ts.type); gfc_add_expr_to_block (&body, tmp); - if (rse.ss != gfc_ss_terminator) - abort (); + gcc_assert (rse.ss == gfc_ss_terminator); /* Generate the copying loops. */ gfc_trans_scalarizing_loops (&loop, &body); @@ -1648,8 +1644,8 @@ gfc_conv_structure (gfc_se * se, gfc_expr * expr, int init) tree type; tree tmp; - assert (se->ss == NULL); - assert (expr->expr_type == EXPR_STRUCTURE); + gcc_assert (se->ss == NULL); + gcc_assert (expr->expr_type == EXPR_STRUCTURE); type = gfc_typenode_for_spec (&expr->ts); if (!init) @@ -1699,7 +1695,7 @@ gfc_conv_substring_expr (gfc_se * se, gfc_expr * expr) ref = expr->ref; - assert(ref->type == REF_SUBSTRING); + gcc_assert (ref->type == REF_SUBSTRING); se->expr = gfc_build_string_const(expr->value.character.length, expr->value.character.string); @@ -1761,7 +1757,7 @@ gfc_conv_expr (gfc_se * se, gfc_expr * expr) break; default: - abort (); + gcc_unreachable (); break; } } @@ -1772,7 +1768,7 @@ gfc_conv_expr_lhs (gfc_se * se, gfc_expr * expr) gfc_conv_expr (se, expr); /* AFAICS all numeric lvalues have empty post chains. If not we need to figure out a way of rewriting an lvalue so that it has no post chain. */ - assert (expr->ts.type != BT_CHARACTER || !se->post.head); + gcc_assert (expr->ts.type != BT_CHARACTER || !se->post.head); } void @@ -1780,7 +1776,7 @@ gfc_conv_expr_val (gfc_se * se, gfc_expr * expr) { tree val; - assert (expr->ts.type != BT_CHARACTER); + gcc_assert (expr->ts.type != BT_CHARACTER); gfc_conv_expr (se, expr); if (se->post.head) { @@ -1885,7 +1881,7 @@ gfc_trans_pointer_assignment (gfc_expr * expr1, gfc_expr * expr2) /* Scalar pointers. */ lse.want_pointer = 1; gfc_conv_expr (&lse, expr1); - assert (rss == gfc_ss_terminator); + gcc_assert (rss == gfc_ss_terminator); gfc_init_se (&rse, NULL); rse.want_pointer = 1; gfc_conv_expr (&rse, expr2); @@ -1936,12 +1932,12 @@ gfc_conv_string_parameter (gfc_se * se) type = TREE_TYPE (se->expr); if (TYPE_STRING_FLAG (type)) { - assert (TREE_CODE (se->expr) != INDIRECT_REF); + gcc_assert (TREE_CODE (se->expr) != INDIRECT_REF); se->expr = gfc_build_addr_expr (pchar_type_node, se->expr); } - assert (POINTER_TYPE_P (TREE_TYPE (se->expr))); - assert (se->string_length + gcc_assert (POINTER_TYPE_P (TREE_TYPE (se->expr))); + gcc_assert (se->string_length && TREE_CODE (TREE_TYPE (se->string_length)) == INTEGER_TYPE); } @@ -1958,7 +1954,7 @@ gfc_trans_scalar_assign (gfc_se * lse, gfc_se * rse, bt type) if (type == BT_CHARACTER) { - assert (lse->string_length != NULL_TREE + gcc_assert (lse->string_length != NULL_TREE && rse->string_length != NULL_TREE); gfc_conv_string_parameter (lse); @@ -2010,12 +2006,12 @@ gfc_trans_arrayfunc_assign (gfc_expr * expr1, gfc_expr * expr2) /* The frontend doesn't seem to bother filling in expr->symtree for intrinsic functions. */ - assert (expr2->value.function.isym + gcc_assert (expr2->value.function.isym || (gfc_return_by_reference (expr2->symtree->n.sym) && expr2->symtree->n.sym->result->attr.dimension)); ss = gfc_walk_expr (expr1); - assert (ss != gfc_ss_terminator); + gcc_assert (ss != gfc_ss_terminator); gfc_init_se (&se, NULL); gfc_start_block (&se.pre); se.want_pointer = 1; @@ -2024,7 +2020,7 @@ gfc_trans_arrayfunc_assign (gfc_expr * expr1, gfc_expr * expr2) se.direct_byref = 1; se.ss = gfc_walk_expr (expr2); - assert (se.ss != gfc_ss_terminator); + gcc_assert (se.ss != gfc_ss_terminator); gfc_conv_function_expr (&se, expr2); gfc_add_block_to_block (&se.pre, &se.post); @@ -2075,7 +2071,7 @@ gfc_trans_assignment (gfc_expr * expr1, gfc_expr * expr2) && lss_section->type != GFC_SS_SECTION) lss_section = lss_section->next; - assert (lss_section != gfc_ss_terminator); + gcc_assert (lss_section != gfc_ss_terminator); /* Initialize the scalarizer. */ gfc_init_loopinfo (&loop); @@ -2146,10 +2142,8 @@ gfc_trans_assignment (gfc_expr * expr1, gfc_expr * expr2) } else { - if (lse.ss != gfc_ss_terminator) - abort (); - if (rse.ss != gfc_ss_terminator) - abort (); + gcc_assert (lse.ss == gfc_ss_terminator + && rse.ss == gfc_ss_terminator); if (loop.temp_ss != NULL) { @@ -2168,11 +2162,8 @@ gfc_trans_assignment (gfc_expr * expr1, gfc_expr * expr2) gfc_advance_se_ss_chain (&rse); gfc_conv_expr (&lse, expr1); - if (lse.ss != gfc_ss_terminator) - abort (); - - if (rse.ss != gfc_ss_terminator) - abort (); + gcc_assert (lse.ss == gfc_ss_terminator + && rse.ss == gfc_ss_terminator); tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts.type); gfc_add_expr_to_block (&body, tmp); |