diff options
author | phython <phython@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-10-02 17:42:44 +0000 |
---|---|---|
committer | phython <phython@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-10-02 17:42:44 +0000 |
commit | 4b97c1145e585bf5461fa9bf8e6cd0f604976641 (patch) | |
tree | 1cfa5994abed8c5eec4b3ca5e3130c1a77c3cc53 /gcc/treelang | |
parent | 33cfe654eb032c3567308979826bcf14e9305e1b (diff) | |
download | gcc-4b97c1145e585bf5461fa9bf8e6cd0f604976641.tar.gz |
2004-10-02 James A. Morrison <phython@gcc.gnu.org>
* parse.y: Use gcc_assert and gcc_unreachable instead of abort.
* tree1.c: Likewise.
* treetree.c: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@88429 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/treelang')
-rw-r--r-- | gcc/treelang/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/treelang/parse.y | 96 | ||||
-rw-r--r-- | gcc/treelang/tree1.c | 9 | ||||
-rw-r--r-- | gcc/treelang/treetree.c | 53 |
4 files changed, 72 insertions, 92 deletions
diff --git a/gcc/treelang/ChangeLog b/gcc/treelang/ChangeLog index 88e85408612..21837cd4882 100644 --- a/gcc/treelang/ChangeLog +++ b/gcc/treelang/ChangeLog @@ -1,5 +1,11 @@ 2004-10-02 James A. Morrison <phython@gcc.gnu.org> + * parse.y: Use gcc_assert and gcc_unreachable instead of abort. + * tree1.c: Likewise. + * treetree.c: Likewise. + +2004-10-02 James A. Morrison <phython@gcc.gnu.org> + * lex.l: Remove random whitespace. * parse.y: Reformat copyright notice. Indent declarations. Wrap long lines, unwrap short lines. diff --git a/gcc/treelang/parse.y b/gcc/treelang/parse.y index b55795d256d..8a1db64954f 100644 --- a/gcc/treelang/parse.y +++ b/gcc/treelang/parse.y @@ -197,8 +197,7 @@ storage typename NAME init_opt SEMICOLON { if (VAR_INIT (prod)) { - if (! ((struct prod_token_parm_item*)VAR_INIT (prod))->tp.pro.code) - abort (); + gcc_assert (((struct prod_token_parm_item*)VAR_INIT (prod))->tp.pro.code); if (STORAGE_CLASS (prod) == EXTERNAL_REFERENCE_STORAGE) { fprintf (stderr, "%s:%i:%i: External reference variables may not have initial value\n", @@ -217,8 +216,7 @@ storage typename NAME init_opt SEMICOLON { VAR_INIT (prod) ? ((struct prod_token_parm_item*)VAR_INIT (prod))->tp.pro.code : NULL, tok->tp.tok.location); - if (!prod->tp.pro.code) - abort (); + gcc_assert (prod->tp.pro.code); } ; @@ -287,7 +285,7 @@ storage typename NAME LEFT_PARENTHESIS parameters_opt RIGHT_PARENTHESIS SEMICOLO break; default: - abort (); + gcc_unreachable (); } type = EXPRESSION_TYPE (prod); /* Create a parameter list in a non-front end specific format. */ @@ -295,16 +293,15 @@ storage typename NAME LEFT_PARENTHESIS parameters_opt RIGHT_PARENTHESIS SEMICOLO this_parm; this_parm = this_parm->tp.pro.next) { - if (this_parm->category != production_category) - abort (); + gcc_assert (this_parm->category == production_category); + this_parm_var = VARIABLE (this_parm); - if (!this_parm_var) - abort (); - if (this_parm_var->category != production_category) - abort (); + + gcc_assert (this_parm_var); + gcc_assert (this_parm_var->category == production_category); + this_parms = my_malloc (sizeof (struct prod_token_parm_item)); - if (!this_parm_var->tp.pro.main_token) - abort (); + gcc_assert (this_parm_var->tp.pro.main_token); this_parms->tp.par.variable_name = this_parm_var->tp.pro.main_token->tp.tok.chars; @@ -353,22 +350,21 @@ NAME LEFT_BRACE { errorcount++; YYERROR; } - if (!proto->tp.pro.code) - abort (); - tree_code_create_function_initial - (proto->tp.pro.code, tok->tp.tok.location, - FIRST_PARMS (current_function)); + gcc_assert (proto->tp.pro.code); + tree_code_create_function_initial (proto->tp.pro.code, tok->tp.tok.location, + FIRST_PARMS (current_function)); + +#ifdef ENABLE_CHECKING /* Check all the parameters have code. */ for (this_parm = PARAMETERS (proto); this_parm; this_parm = this_parm->tp.pro.next) { - if (! (struct prod_token_parm_item*)VARIABLE (this_parm)) - abort (); - if (! (( (struct prod_token_parm_item*)VARIABLE (this_parm))->tp.pro.code)) - abort (); + gcc_assert ((struct prod_token_parm_item*)VARIABLE (this_parm)); + gcc_assert ((( (struct prod_token_parm_item*)VARIABLE (this_parm))->tp.pro.code)); } +#endif } variable_defs_opt statements_opt RIGHT_BRACE { struct prod_token_parm_item* tok; @@ -555,12 +551,12 @@ tl_RETURN expression_opt { /* Check same type. */ if (check_type_match (NUMERIC_TYPE (type_prod), $2)) { - if (!type_prod->tp.pro.code) - abort (); - if (!exp->tp.pro.code) - abort (); + gcc_assert (type_prod->tp.pro.code); + gcc_assert (exp->tp.pro.code); + /* Generate the code. */ - tree_code_generate_return (type_prod->tp.pro.code, exp->tp.pro.code); + tree_code_generate_return (type_prod->tp.pro.code, + exp->tp.pro.code); } } } @@ -573,8 +569,7 @@ expression_opt: |expression { struct prod_token_parm_item *exp; exp = $1; - if (!exp->tp.pro.code) - abort (); + gcc_assert (exp->tp.pro.code); $$ = $1; } @@ -680,20 +675,19 @@ NAME LEFT_PARENTHESIS expressions_with_commas RIGHT_PARENTHESIS { for (exp_proto = PARAMETERS (proto), exp = PARAMETERS (prod); exp_proto; exp = exp->tp.pro.next, exp_proto = exp_proto->tp.pro.next) - { - if (!exp) - abort (); - if (!exp_proto) - abort (); - if (!exp->tp.pro.code) - abort (); - var = VARIABLE (exp_proto); - if (!var) - abort (); - if (!var->tp.pro.code) - abort (); - parms = tree_code_add_parameter (parms, var->tp.pro.code, exp->tp.pro.code); - } + { + gcc_assert (exp); + gcc_assert (exp_proto); + gcc_assert (exp->tp.pro.code); + + var = VARIABLE (exp_proto); + + gcc_assert (var); + gcc_assert (var->tp.pro.code); + + parms = tree_code_add_parameter (parms, var->tp.pro.code, + exp->tp.pro.code); + } type = tree_code_get_type (NUMERIC_TYPE (prod)); prod->tp.pro.code = tree_code_get_expression (EXP_FUNCTION_INVOCATION, type, proto->tp.pro.code, parms, @@ -826,8 +820,7 @@ reverse_prod_list (struct prod_token_parm_item *old_first) while (current) { - if (current->category != production_category) - abort (); + gcc_assert (current->category == production_category); next = current->tp.pro.next; current->tp.pro.next = prev; prev = current; @@ -888,18 +881,14 @@ check_type_match (int type_num, struct prod_token_parm_item *exp) return 1; case VOID_TYPE: - abort (); - default: - abort (); + gcc_unreachable (); } break; case VOID_TYPE: - abort (); - default: - abort (); + gcc_unreachable (); } } @@ -943,8 +932,7 @@ make_plus_expression (struct prod_token_parm_item* tok, NUMERIC_TYPE (prod) = type_code; type = tree_code_get_type (type_code); - if (!type) - abort (); + gcc_assert (type); OP1 (prod) = op1; OP2 (prod) = op2; @@ -982,7 +970,7 @@ set_storage (struct prod_token_parm_item *prod) break; default: - abort (); + gcc_unreachable (); } } diff --git a/gcc/treelang/tree1.c b/gcc/treelang/tree1.c index 5a3e3d10a93..a734615f091 100644 --- a/gcc/treelang/tree1.c +++ b/gcc/treelang/tree1.c @@ -104,9 +104,6 @@ treelang_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED, switch (code) { - default: - abort(); - case OPT_v: if (!version_done) { @@ -129,6 +126,10 @@ treelang_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED, case OPT_flexer_trace: option_lexer_trace = value; break; + + default: + gcc_unreachable (); + } return 1; @@ -294,7 +295,7 @@ sanity_check (struct prod_token_parm_item *item) break; default: - abort (); + gcc_unreachable (); } } diff --git a/gcc/treelang/treetree.c b/gcc/treelang/treetree.c index a559c5d57a0..ade0d9d99c7 100644 --- a/gcc/treelang/treetree.c +++ b/gcc/treelang/treetree.c @@ -245,7 +245,7 @@ tree_code_get_type (int type_num) return void_type_node; default: - abort (); + gcc_unreachable (); } } @@ -330,8 +330,7 @@ tree_code_create_function_prototype (unsigned char* chars, id = get_identifier ((const char*)chars); for (parm = parms; parm; parm = parm->tp.par.next) { - if (parm->category != parameter_category) - abort (); + gcc_assert (parm->category == parameter_category); type_node = tree_code_get_type (parm->type); type_list = tree_cons (NULL_TREE, type_node, type_list); } @@ -375,7 +374,7 @@ tree_code_create_function_prototype (unsigned char* chars, case AUTOMATIC_STORAGE: default: - abort (); + gcc_unreachable (); } /* Process declaration of function defined elsewhere. */ @@ -403,8 +402,7 @@ tree_code_create_function_initial (tree prev_saved, struct prod_token_parm_item* parm; fn_decl = prev_saved; - if (!fn_decl) - abort (); + gcc_assert (fn_decl); /* Output message if not -quiet. */ announce_function (fn_decl); @@ -437,10 +435,8 @@ tree_code_create_function_initial (tree prev_saved, /* Some languages have different nominal and real types. */ DECL_ARG_TYPE (parm_decl) = TREE_TYPE (parm_decl); - if (!DECL_ARG_TYPE (parm_decl)) - abort (); - if (!fn_decl) - abort (); + gcc_assert (DECL_ARG_TYPE (parm_decl)); + gcc_assert (fn_decl); DECL_CONTEXT (parm_decl) = fn_decl; DECL_SOURCE_LOCATION (parm_decl) = loc; parm_list = chainon (parm_decl, parm_list); @@ -458,12 +454,10 @@ tree_code_create_function_initial (tree prev_saved, param_decl = TREE_CHAIN (param_decl), this_parm = this_parm->tp.par.next) { - if (!this_parm) - abort (); /* Too few. */ + gcc_assert (this_parm); /* Too few. */ *this_parm->tp.par.where_to_put_var_tree = param_decl; } - if (this_parm) - abort (); /* Too many. */ + gcc_assert (!this_parm); /* Too many. */ /* Create a new level at the start of the function. */ @@ -541,8 +535,7 @@ tree_code_create_variable (unsigned int storage_class, var_type = tree_code_get_type (expression_type); /* 2. Build the name. */ - if (chars[length] != 0) - abort (); /* Should be null terminated. */ + gcc_assert (chars[length] == 0); /* Should be null terminated. */ var_id = get_identifier ((const char*)chars); @@ -555,8 +548,7 @@ tree_code_create_variable (unsigned int storage_class, else DECL_INITIAL (var_decl) = NULL_TREE; - if (TYPE_SIZE (var_type) == 0) - abort (); /* Did not calculate size. */ + gcc_assert (TYPE_SIZE (var_type) != 0); /* Did not calculate size. */ DECL_CONTEXT (var_decl) = current_function_decl; @@ -586,7 +578,7 @@ tree_code_create_variable (unsigned int storage_class, break; default: - abort (); + gcc_unreachable (); } /* This should really only be set if the variable is used. */ @@ -611,13 +603,12 @@ tree_code_generate_return (tree type, tree exp) tree setret; tree param; +#ifdef ENABLE_CHECKING for (param = DECL_ARGUMENTS (current_function_decl); param; param = TREE_CHAIN (param)) - { - if (DECL_CONTEXT (param) != current_function_decl) - abort (); - } + gcc_assert (DECL_CONTEXT (param) == current_function_decl); +#endif if (exp && TREE_TYPE (TREE_TYPE (current_function_decl)) != void_type_node) { @@ -692,12 +683,10 @@ tree_code_get_expression (unsigned int exp_type, switch (exp_type) { case EXP_ASSIGN: - if (!op1 || !op2) - abort (); + gcc_assert (op1 && op2); operator = MODIFY_EXPR; ret1 = fold (build2 (operator, void_type_node, op1, fold (build1 (CONVERT_EXPR, TREE_TYPE (op1), op2)))); - break; case EXP_PLUS: @@ -714,8 +703,7 @@ tree_code_get_expression (unsigned int exp_type, /* Expand a binary expression. Ensure the operands are the right type. */ binary_expression: - if (!op1 || !op2) - abort (); + gcc_assert (op1 && op2); ret1 = fold (build2 (operator, type, fold (build1 (CONVERT_EXPR, type, op1)), fold (build1 (CONVERT_EXPR, type, op2)))); @@ -725,8 +713,7 @@ tree_code_get_expression (unsigned int exp_type, decl for the variable. If the TYPE is different than the variable type, convert it. */ case EXP_REFERENCE: - if (!op1) - abort (); + gcc_assert (op1); if (type == TREE_TYPE (op1)) ret1 = op1; else @@ -734,9 +721,7 @@ tree_code_get_expression (unsigned int exp_type, break; case EXP_FUNCTION_INVOCATION: - if (!op1 || !op2) - abort (); - + gcc_assert (op1 && op2); { tree fun_ptr; fun_ptr = fold (build1 (ADDR_EXPR, @@ -746,7 +731,7 @@ tree_code_get_expression (unsigned int exp_type, break; default: - abort (); + gcc_unreachable (); } return ret1; |