various null-dereference problems fixed
This commit is contained in:
parent
c84c57be67
commit
5927f264a8
|
@ -183,6 +183,11 @@ begin_proc(name, def) /* to be called when entering a procedure */
|
||||||
DfaStartFunction(name);
|
DfaStartFunction(name);
|
||||||
#endif DATAFLOW
|
#endif DATAFLOW
|
||||||
|
|
||||||
|
if (def->df_type->tp_fund != FUNCTION) {
|
||||||
|
error("making function body for non-function");
|
||||||
|
func_tp = error_type;
|
||||||
|
}
|
||||||
|
else
|
||||||
func_tp = def->df_type->tp_up;
|
func_tp = def->df_type->tp_up;
|
||||||
size = ATW(func_tp->tp_size);
|
size = ATW(func_tp->tp_size);
|
||||||
C_pro_narg(name);
|
C_pro_narg(name);
|
||||||
|
|
|
@ -171,6 +171,7 @@ idf2expr(expr)
|
||||||
/* now def != 0 */
|
/* now def != 0 */
|
||||||
if (def->df_type->tp_fund == LABEL) {
|
if (def->df_type->tp_fund == LABEL) {
|
||||||
expr_error(expr, "illegal use of label %s", idf->id_text);
|
expr_error(expr, "illegal use of label %s", idf->id_text);
|
||||||
|
expr->ex_type = error_type;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
def->df_used = 1;
|
def->df_used = 1;
|
||||||
|
|
|
@ -181,7 +181,7 @@ declare_idf(ds, dc, lvl)
|
||||||
/* at the L_FORMAL1 level there is no type specified yet
|
/* at the L_FORMAL1 level there is no type specified yet
|
||||||
*/
|
*/
|
||||||
ASSERT(lvl == L_FORMAL1);
|
ASSERT(lvl == L_FORMAL1);
|
||||||
type = 0;
|
type = int_type; /* may change at L_FORMAL2 */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* combine the decspecs and the declarator into one type */
|
/* combine the decspecs and the declarator into one type */
|
||||||
|
@ -583,7 +583,7 @@ declare_parameter(idf)
|
||||||
{
|
{
|
||||||
/* idf is declared as a formal.
|
/* idf is declared as a formal.
|
||||||
*/
|
*/
|
||||||
add_def(idf, FORMAL, (struct type *)0, level);
|
add_def(idf, FORMAL, int_type, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_enum(tp, idf, l)
|
declare_enum(tp, idf, l)
|
||||||
|
@ -616,8 +616,6 @@ declare_formals(fp)
|
||||||
struct idf *idf = se->se_idf;
|
struct idf *idf = se->se_idf;
|
||||||
struct def *def = idf->id_def;
|
struct def *def = idf->id_def;
|
||||||
|
|
||||||
if (def->df_type == 0)
|
|
||||||
def->df_type = int_type; /* default type */
|
|
||||||
def->df_address = f_offset;
|
def->df_address = f_offset;
|
||||||
|
|
||||||
/* the alignment convention for parameters is: align on
|
/* the alignment convention for parameters is: align on
|
||||||
|
|
|
@ -279,7 +279,7 @@ switch_statement
|
||||||
'('
|
'('
|
||||||
expression(&expr)
|
expression(&expr)
|
||||||
{
|
{
|
||||||
code_startswitch(expr);
|
code_startswitch(&expr);
|
||||||
}
|
}
|
||||||
')'
|
')'
|
||||||
statement
|
statement
|
||||||
|
|
|
@ -310,7 +310,7 @@ idf2sdef(idf, tp)
|
||||||
*sdefp = sdef = new_sdef();
|
*sdefp = sdef = new_sdef();
|
||||||
clear((char *)sdef, sizeof(struct sdef));
|
clear((char *)sdef, sizeof(struct sdef));
|
||||||
sdef->sd_idf = idf;
|
sdef->sd_idf = idf;
|
||||||
sdef->sd_type = error_type;
|
sdef->sd_stype = sdef->sd_type = error_type;
|
||||||
return sdef;
|
return sdef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,8 @@ static struct switch_hdr *switch_stack = 0;
|
||||||
For simplicity, we suppose int_size == word_size.
|
For simplicity, we suppose int_size == word_size.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
code_startswitch(expr)
|
code_startswitch(expp)
|
||||||
struct expr *expr;
|
struct expr **expp;
|
||||||
{
|
{
|
||||||
/* Check the expression, stack a new case header and
|
/* Check the expression, stack a new case header and
|
||||||
fill in the necessary fields.
|
fill in the necessary fields.
|
||||||
|
@ -41,17 +41,17 @@ code_startswitch(expr)
|
||||||
register label l_table = text_label();
|
register label l_table = text_label();
|
||||||
register label l_break = text_label();
|
register label l_break = text_label();
|
||||||
register struct switch_hdr *sh = new_switch_hdr();
|
register struct switch_hdr *sh = new_switch_hdr();
|
||||||
int fund = any2arith(&expr, SWITCH); /* INT, LONG or DOUBLE */
|
int fund = any2arith(expp, SWITCH); /* INT, LONG or DOUBLE */
|
||||||
|
|
||||||
switch (fund) {
|
switch (fund) {
|
||||||
case LONG:
|
case LONG:
|
||||||
if (options['R'])
|
if (options['R'])
|
||||||
warning("long in switch (cast to int)");
|
warning("long in switch (cast to int)");
|
||||||
int2int(&expr, int_type);
|
int2int(expp, int_type);
|
||||||
break;
|
break;
|
||||||
case DOUBLE:
|
case DOUBLE:
|
||||||
error("float/double in switch");
|
error("float/double in switch");
|
||||||
erroneous2int(&expr);
|
erroneous2int(expp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,12 +60,12 @@ code_startswitch(expr)
|
||||||
sh->sh_default = 0;
|
sh->sh_default = 0;
|
||||||
sh->sh_table = l_table;
|
sh->sh_table = l_table;
|
||||||
sh->sh_nrofentries = 0;
|
sh->sh_nrofentries = 0;
|
||||||
sh->sh_type = expr->ex_type; /* the expression switched */
|
sh->sh_type = (*expp)->ex_type; /* the expression switched */
|
||||||
sh->sh_lowerbd = sh->sh_upperbd = (arith)0; /* immaterial ??? */
|
sh->sh_lowerbd = sh->sh_upperbd = (arith)0; /* immaterial ??? */
|
||||||
sh->sh_entries = (struct case_entry *) 0; /* case-entry list */
|
sh->sh_entries = (struct case_entry *) 0; /* case-entry list */
|
||||||
sh->next = switch_stack; /* push onto switch-stack */
|
sh->next = switch_stack; /* push onto switch-stack */
|
||||||
switch_stack = sh;
|
switch_stack = sh;
|
||||||
code_expr(expr, RVAL, TRUE, NO_LABEL, NO_LABEL);
|
code_expr(*expp, RVAL, TRUE, NO_LABEL, NO_LABEL);
|
||||||
/* evaluate the switch expr. */
|
/* evaluate the switch expr. */
|
||||||
C_bra(l_table); /* goto start of switch_table */
|
C_bra(l_table); /* goto start of switch_table */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue