Commit 039784fa by James A. Morrison

parse.y: Use gcc_assert and gcc_unreachable instead of abort.

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.

From-SVN: r88429
parent 7e57da12
2004-10-02 James A. Morrison <phython@gcc.gnu.org> 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. * lex.l: Remove random whitespace.
* parse.y: Reformat copyright notice. Indent declarations. * parse.y: Reformat copyright notice. Indent declarations.
Wrap long lines, unwrap short lines. Wrap long lines, unwrap short lines.
......
...@@ -197,8 +197,7 @@ storage typename NAME init_opt SEMICOLON { ...@@ -197,8 +197,7 @@ storage typename NAME init_opt SEMICOLON {
if (VAR_INIT (prod)) if (VAR_INIT (prod))
{ {
if (! ((struct prod_token_parm_item*)VAR_INIT (prod))->tp.pro.code) gcc_assert (((struct prod_token_parm_item*)VAR_INIT (prod))->tp.pro.code);
abort ();
if (STORAGE_CLASS (prod) == EXTERNAL_REFERENCE_STORAGE) if (STORAGE_CLASS (prod) == EXTERNAL_REFERENCE_STORAGE)
{ {
fprintf (stderr, "%s:%i:%i: External reference variables may not have initial value\n", fprintf (stderr, "%s:%i:%i: External reference variables may not have initial value\n",
...@@ -217,8 +216,7 @@ storage typename NAME init_opt SEMICOLON { ...@@ -217,8 +216,7 @@ storage typename NAME init_opt SEMICOLON {
VAR_INIT (prod) ? VAR_INIT (prod) ?
((struct prod_token_parm_item*)VAR_INIT (prod))->tp.pro.code : NULL, ((struct prod_token_parm_item*)VAR_INIT (prod))->tp.pro.code : NULL,
tok->tp.tok.location); tok->tp.tok.location);
if (!prod->tp.pro.code) gcc_assert (prod->tp.pro.code);
abort ();
} }
; ;
...@@ -287,7 +285,7 @@ storage typename NAME LEFT_PARENTHESIS parameters_opt RIGHT_PARENTHESIS SEMICOLO ...@@ -287,7 +285,7 @@ storage typename NAME LEFT_PARENTHESIS parameters_opt RIGHT_PARENTHESIS SEMICOLO
break; break;
default: default:
abort (); gcc_unreachable ();
} }
type = EXPRESSION_TYPE (prod); type = EXPRESSION_TYPE (prod);
/* Create a parameter list in a non-front end specific format. */ /* 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 ...@@ -295,16 +293,15 @@ storage typename NAME LEFT_PARENTHESIS parameters_opt RIGHT_PARENTHESIS SEMICOLO
this_parm; this_parm;
this_parm = this_parm->tp.pro.next) this_parm = this_parm->tp.pro.next)
{ {
if (this_parm->category != production_category) gcc_assert (this_parm->category == production_category);
abort ();
this_parm_var = VARIABLE (this_parm); this_parm_var = VARIABLE (this_parm);
if (!this_parm_var)
abort (); gcc_assert (this_parm_var);
if (this_parm_var->category != production_category) gcc_assert (this_parm_var->category == production_category);
abort ();
this_parms = my_malloc (sizeof (struct prod_token_parm_item)); this_parms = my_malloc (sizeof (struct prod_token_parm_item));
if (!this_parm_var->tp.pro.main_token) gcc_assert (this_parm_var->tp.pro.main_token);
abort ();
this_parms->tp.par.variable_name = this_parms->tp.par.variable_name =
this_parm_var->tp.pro.main_token->tp.tok.chars; this_parm_var->tp.pro.main_token->tp.tok.chars;
...@@ -353,22 +350,21 @@ NAME LEFT_BRACE { ...@@ -353,22 +350,21 @@ NAME LEFT_BRACE {
errorcount++; errorcount++;
YYERROR; YYERROR;
} }
if (!proto->tp.pro.code) gcc_assert (proto->tp.pro.code);
abort ();
tree_code_create_function_initial
(proto->tp.pro.code, tok->tp.tok.location,
FIRST_PARMS (current_function));
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. */ /* Check all the parameters have code. */
for (this_parm = PARAMETERS (proto); for (this_parm = PARAMETERS (proto);
this_parm; this_parm;
this_parm = this_parm->tp.pro.next) this_parm = this_parm->tp.pro.next)
{ {
if (! (struct prod_token_parm_item*)VARIABLE (this_parm)) gcc_assert ((struct prod_token_parm_item*)VARIABLE (this_parm));
abort (); gcc_assert ((( (struct prod_token_parm_item*)VARIABLE (this_parm))->tp.pro.code));
if (! (( (struct prod_token_parm_item*)VARIABLE (this_parm))->tp.pro.code))
abort ();
} }
#endif
} }
variable_defs_opt statements_opt RIGHT_BRACE { variable_defs_opt statements_opt RIGHT_BRACE {
struct prod_token_parm_item* tok; struct prod_token_parm_item* tok;
...@@ -555,12 +551,12 @@ tl_RETURN expression_opt { ...@@ -555,12 +551,12 @@ tl_RETURN expression_opt {
/* Check same type. */ /* Check same type. */
if (check_type_match (NUMERIC_TYPE (type_prod), $2)) if (check_type_match (NUMERIC_TYPE (type_prod), $2))
{ {
if (!type_prod->tp.pro.code) gcc_assert (type_prod->tp.pro.code);
abort (); gcc_assert (exp->tp.pro.code);
if (!exp->tp.pro.code)
abort ();
/* Generate the 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: ...@@ -573,8 +569,7 @@ expression_opt:
|expression { |expression {
struct prod_token_parm_item *exp; struct prod_token_parm_item *exp;
exp = $1; exp = $1;
if (!exp->tp.pro.code) gcc_assert (exp->tp.pro.code);
abort ();
$$ = $1; $$ = $1;
} }
...@@ -680,20 +675,19 @@ NAME LEFT_PARENTHESIS expressions_with_commas RIGHT_PARENTHESIS { ...@@ -680,20 +675,19 @@ NAME LEFT_PARENTHESIS expressions_with_commas RIGHT_PARENTHESIS {
for (exp_proto = PARAMETERS (proto), exp = PARAMETERS (prod); for (exp_proto = PARAMETERS (proto), exp = PARAMETERS (prod);
exp_proto; exp_proto;
exp = exp->tp.pro.next, exp_proto = exp_proto->tp.pro.next) exp = exp->tp.pro.next, exp_proto = exp_proto->tp.pro.next)
{ {
if (!exp) gcc_assert (exp);
abort (); gcc_assert (exp_proto);
if (!exp_proto) gcc_assert (exp->tp.pro.code);
abort ();
if (!exp->tp.pro.code) var = VARIABLE (exp_proto);
abort ();
var = VARIABLE (exp_proto); gcc_assert (var);
if (!var) gcc_assert (var->tp.pro.code);
abort ();
if (!var->tp.pro.code) parms = tree_code_add_parameter (parms, var->tp.pro.code,
abort (); exp->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)); type = tree_code_get_type (NUMERIC_TYPE (prod));
prod->tp.pro.code = tree_code_get_expression (EXP_FUNCTION_INVOCATION, type, prod->tp.pro.code = tree_code_get_expression (EXP_FUNCTION_INVOCATION, type,
proto->tp.pro.code, parms, proto->tp.pro.code, parms,
...@@ -826,8 +820,7 @@ reverse_prod_list (struct prod_token_parm_item *old_first) ...@@ -826,8 +820,7 @@ reverse_prod_list (struct prod_token_parm_item *old_first)
while (current) while (current)
{ {
if (current->category != production_category) gcc_assert (current->category == production_category);
abort ();
next = current->tp.pro.next; next = current->tp.pro.next;
current->tp.pro.next = prev; current->tp.pro.next = prev;
prev = current; prev = current;
...@@ -888,18 +881,14 @@ check_type_match (int type_num, struct prod_token_parm_item *exp) ...@@ -888,18 +881,14 @@ check_type_match (int type_num, struct prod_token_parm_item *exp)
return 1; return 1;
case VOID_TYPE: case VOID_TYPE:
abort ();
default: default:
abort (); gcc_unreachable ();
} }
break; break;
case VOID_TYPE: case VOID_TYPE:
abort ();
default: default:
abort (); gcc_unreachable ();
} }
} }
...@@ -943,8 +932,7 @@ make_plus_expression (struct prod_token_parm_item* tok, ...@@ -943,8 +932,7 @@ make_plus_expression (struct prod_token_parm_item* tok,
NUMERIC_TYPE (prod) = type_code; NUMERIC_TYPE (prod) = type_code;
type = tree_code_get_type (type_code); type = tree_code_get_type (type_code);
if (!type) gcc_assert (type);
abort ();
OP1 (prod) = op1; OP1 (prod) = op1;
OP2 (prod) = op2; OP2 (prod) = op2;
...@@ -982,7 +970,7 @@ set_storage (struct prod_token_parm_item *prod) ...@@ -982,7 +970,7 @@ set_storage (struct prod_token_parm_item *prod)
break; break;
default: default:
abort (); gcc_unreachable ();
} }
} }
......
...@@ -104,9 +104,6 @@ treelang_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED, ...@@ -104,9 +104,6 @@ treelang_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED,
switch (code) switch (code)
{ {
default:
abort();
case OPT_v: case OPT_v:
if (!version_done) if (!version_done)
{ {
...@@ -129,6 +126,10 @@ treelang_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED, ...@@ -129,6 +126,10 @@ treelang_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED,
case OPT_flexer_trace: case OPT_flexer_trace:
option_lexer_trace = value; option_lexer_trace = value;
break; break;
default:
gcc_unreachable ();
} }
return 1; return 1;
...@@ -294,7 +295,7 @@ sanity_check (struct prod_token_parm_item *item) ...@@ -294,7 +295,7 @@ sanity_check (struct prod_token_parm_item *item)
break; break;
default: default:
abort (); gcc_unreachable ();
} }
} }
......
...@@ -245,7 +245,7 @@ tree_code_get_type (int type_num) ...@@ -245,7 +245,7 @@ tree_code_get_type (int type_num)
return void_type_node; return void_type_node;
default: default:
abort (); gcc_unreachable ();
} }
} }
...@@ -330,8 +330,7 @@ tree_code_create_function_prototype (unsigned char* chars, ...@@ -330,8 +330,7 @@ tree_code_create_function_prototype (unsigned char* chars,
id = get_identifier ((const char*)chars); id = get_identifier ((const char*)chars);
for (parm = parms; parm; parm = parm->tp.par.next) for (parm = parms; parm; parm = parm->tp.par.next)
{ {
if (parm->category != parameter_category) gcc_assert (parm->category == parameter_category);
abort ();
type_node = tree_code_get_type (parm->type); type_node = tree_code_get_type (parm->type);
type_list = tree_cons (NULL_TREE, type_node, type_list); type_list = tree_cons (NULL_TREE, type_node, type_list);
} }
...@@ -375,7 +374,7 @@ tree_code_create_function_prototype (unsigned char* chars, ...@@ -375,7 +374,7 @@ tree_code_create_function_prototype (unsigned char* chars,
case AUTOMATIC_STORAGE: case AUTOMATIC_STORAGE:
default: default:
abort (); gcc_unreachable ();
} }
/* Process declaration of function defined elsewhere. */ /* Process declaration of function defined elsewhere. */
...@@ -403,8 +402,7 @@ tree_code_create_function_initial (tree prev_saved, ...@@ -403,8 +402,7 @@ tree_code_create_function_initial (tree prev_saved,
struct prod_token_parm_item* parm; struct prod_token_parm_item* parm;
fn_decl = prev_saved; fn_decl = prev_saved;
if (!fn_decl) gcc_assert (fn_decl);
abort ();
/* Output message if not -quiet. */ /* Output message if not -quiet. */
announce_function (fn_decl); announce_function (fn_decl);
...@@ -437,10 +435,8 @@ tree_code_create_function_initial (tree prev_saved, ...@@ -437,10 +435,8 @@ tree_code_create_function_initial (tree prev_saved,
/* Some languages have different nominal and real types. */ /* Some languages have different nominal and real types. */
DECL_ARG_TYPE (parm_decl) = TREE_TYPE (parm_decl); DECL_ARG_TYPE (parm_decl) = TREE_TYPE (parm_decl);
if (!DECL_ARG_TYPE (parm_decl)) gcc_assert (DECL_ARG_TYPE (parm_decl));
abort (); gcc_assert (fn_decl);
if (!fn_decl)
abort ();
DECL_CONTEXT (parm_decl) = fn_decl; DECL_CONTEXT (parm_decl) = fn_decl;
DECL_SOURCE_LOCATION (parm_decl) = loc; DECL_SOURCE_LOCATION (parm_decl) = loc;
parm_list = chainon (parm_decl, parm_list); parm_list = chainon (parm_decl, parm_list);
...@@ -458,12 +454,10 @@ tree_code_create_function_initial (tree prev_saved, ...@@ -458,12 +454,10 @@ tree_code_create_function_initial (tree prev_saved,
param_decl = TREE_CHAIN (param_decl), param_decl = TREE_CHAIN (param_decl),
this_parm = this_parm->tp.par.next) this_parm = this_parm->tp.par.next)
{ {
if (!this_parm) gcc_assert (this_parm); /* Too few. */
abort (); /* Too few. */
*this_parm->tp.par.where_to_put_var_tree = param_decl; *this_parm->tp.par.where_to_put_var_tree = param_decl;
} }
if (this_parm) gcc_assert (!this_parm); /* Too many. */
abort (); /* Too many. */
/* Create a new level at the start of the function. */ /* Create a new level at the start of the function. */
...@@ -541,8 +535,7 @@ tree_code_create_variable (unsigned int storage_class, ...@@ -541,8 +535,7 @@ tree_code_create_variable (unsigned int storage_class,
var_type = tree_code_get_type (expression_type); var_type = tree_code_get_type (expression_type);
/* 2. Build the name. */ /* 2. Build the name. */
if (chars[length] != 0) gcc_assert (chars[length] == 0); /* Should be null terminated. */
abort (); /* Should be null terminated. */
var_id = get_identifier ((const char*)chars); var_id = get_identifier ((const char*)chars);
...@@ -555,8 +548,7 @@ tree_code_create_variable (unsigned int storage_class, ...@@ -555,8 +548,7 @@ tree_code_create_variable (unsigned int storage_class,
else else
DECL_INITIAL (var_decl) = NULL_TREE; DECL_INITIAL (var_decl) = NULL_TREE;
if (TYPE_SIZE (var_type) == 0) gcc_assert (TYPE_SIZE (var_type) != 0); /* Did not calculate size. */
abort (); /* Did not calculate size. */
DECL_CONTEXT (var_decl) = current_function_decl; DECL_CONTEXT (var_decl) = current_function_decl;
...@@ -586,7 +578,7 @@ tree_code_create_variable (unsigned int storage_class, ...@@ -586,7 +578,7 @@ tree_code_create_variable (unsigned int storage_class,
break; break;
default: default:
abort (); gcc_unreachable ();
} }
/* This should really only be set if the variable is used. */ /* This should really only be set if the variable is used. */
...@@ -611,13 +603,12 @@ tree_code_generate_return (tree type, tree exp) ...@@ -611,13 +603,12 @@ tree_code_generate_return (tree type, tree exp)
tree setret; tree setret;
tree param; tree param;
#ifdef ENABLE_CHECKING
for (param = DECL_ARGUMENTS (current_function_decl); for (param = DECL_ARGUMENTS (current_function_decl);
param; param;
param = TREE_CHAIN (param)) param = TREE_CHAIN (param))
{ gcc_assert (DECL_CONTEXT (param) == current_function_decl);
if (DECL_CONTEXT (param) != current_function_decl) #endif
abort ();
}
if (exp && TREE_TYPE (TREE_TYPE (current_function_decl)) != void_type_node) if (exp && TREE_TYPE (TREE_TYPE (current_function_decl)) != void_type_node)
{ {
...@@ -692,12 +683,10 @@ tree_code_get_expression (unsigned int exp_type, ...@@ -692,12 +683,10 @@ tree_code_get_expression (unsigned int exp_type,
switch (exp_type) switch (exp_type)
{ {
case EXP_ASSIGN: case EXP_ASSIGN:
if (!op1 || !op2) gcc_assert (op1 && op2);
abort ();
operator = MODIFY_EXPR; operator = MODIFY_EXPR;
ret1 = fold (build2 (operator, void_type_node, op1, ret1 = fold (build2 (operator, void_type_node, op1,
fold (build1 (CONVERT_EXPR, TREE_TYPE (op1), op2)))); fold (build1 (CONVERT_EXPR, TREE_TYPE (op1), op2))));
break; break;
case EXP_PLUS: case EXP_PLUS:
...@@ -714,8 +703,7 @@ tree_code_get_expression (unsigned int exp_type, ...@@ -714,8 +703,7 @@ tree_code_get_expression (unsigned int exp_type,
/* Expand a binary expression. Ensure the operands are the right type. */ /* Expand a binary expression. Ensure the operands are the right type. */
binary_expression: binary_expression:
if (!op1 || !op2) gcc_assert (op1 && op2);
abort ();
ret1 = fold (build2 (operator, type, ret1 = fold (build2 (operator, type,
fold (build1 (CONVERT_EXPR, type, op1)), fold (build1 (CONVERT_EXPR, type, op1)),
fold (build1 (CONVERT_EXPR, type, op2)))); fold (build1 (CONVERT_EXPR, type, op2))));
...@@ -725,8 +713,7 @@ tree_code_get_expression (unsigned int exp_type, ...@@ -725,8 +713,7 @@ tree_code_get_expression (unsigned int exp_type,
decl for the variable. If the TYPE is different than the decl for the variable. If the TYPE is different than the
variable type, convert it. */ variable type, convert it. */
case EXP_REFERENCE: case EXP_REFERENCE:
if (!op1) gcc_assert (op1);
abort ();
if (type == TREE_TYPE (op1)) if (type == TREE_TYPE (op1))
ret1 = op1; ret1 = op1;
else else
...@@ -734,9 +721,7 @@ tree_code_get_expression (unsigned int exp_type, ...@@ -734,9 +721,7 @@ tree_code_get_expression (unsigned int exp_type,
break; break;
case EXP_FUNCTION_INVOCATION: case EXP_FUNCTION_INVOCATION:
if (!op1 || !op2) gcc_assert (op1 && op2);
abort ();
{ {
tree fun_ptr; tree fun_ptr;
fun_ptr = fold (build1 (ADDR_EXPR, fun_ptr = fold (build1 (ADDR_EXPR,
...@@ -746,7 +731,7 @@ tree_code_get_expression (unsigned int exp_type, ...@@ -746,7 +731,7 @@ tree_code_get_expression (unsigned int exp_type,
break; break;
default: default:
abort (); gcc_unreachable ();
} }
return ret1; return ret1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment