fixed memory fault, adapted mechanism code_scope
This commit is contained in:
parent
d72e4424cd
commit
2db075ab69
3 changed files with 18 additions and 20 deletions
|
@ -382,11 +382,6 @@ code_declaration(idf, expr, lvl, sc)
|
|||
return;
|
||||
if (sc == EXTERN && expr && !is_anon_idf(idf))
|
||||
error("%s is extern; cannot initialize", idf->id_text);
|
||||
#ifndef PREPEND_SCOPES
|
||||
if (def->df_type->tp_fund == FUNCTION) {
|
||||
code_scope(idf->id_text, def);
|
||||
}
|
||||
#endif PREPEND_SCOPES
|
||||
if (lvl == L_GLOBAL) { /* global variable */
|
||||
/* is this an allocating declaration? */
|
||||
if ( (sc == 0 || sc == STATIC)
|
||||
|
@ -429,9 +424,6 @@ code_declaration(idf, expr, lvl, sc)
|
|||
case GLOBAL:
|
||||
case IMPLICIT:
|
||||
/* we are sure there is no expression */
|
||||
#ifndef PREPEND_SCOPES
|
||||
code_scope(idf->id_text, def);
|
||||
#endif PREPEND_SCOPES
|
||||
break;
|
||||
case AUTO:
|
||||
case REGISTER:
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "sizes.h"
|
||||
#include "level.h"
|
||||
#include "noRoption.h"
|
||||
#include "use_tmp.h"
|
||||
|
||||
extern char *symbol2str();
|
||||
extern char options[];
|
||||
|
@ -183,7 +184,12 @@ idf2expr(expr)
|
|||
}
|
||||
else {
|
||||
#ifndef LINT
|
||||
def->df_used = 1;
|
||||
if (! def->df_used) {
|
||||
def->df_used = 1;
|
||||
#ifndef PREPEND_SCOPES
|
||||
code_scope(idf->id_text, def);
|
||||
#endif PREPEND_SCOPES
|
||||
}
|
||||
#endif LINT
|
||||
expr->ex_type = def->df_type;
|
||||
if (expr->ex_type == error_type)
|
||||
|
|
|
@ -38,6 +38,7 @@ char *long2str();
|
|||
char *strncpy();
|
||||
extern char options[];
|
||||
static int gen_error;
|
||||
static int pack_level;
|
||||
struct type **gen_tphead(), **gen_tpmiddle();
|
||||
struct sdef *gen_align_to_next();
|
||||
struct e_stack *p_stack;
|
||||
|
@ -69,7 +70,6 @@ initial_value(register struct type **tpp; register struct expr **expp;) :
|
|||
;
|
||||
|
||||
initial_value_pack(struct type **tpp; struct expr **expp;)
|
||||
{ static int pack_level; }
|
||||
:
|
||||
'{'
|
||||
{ if (pack_level == 0) gen_error = 0; pack_level++; }
|
||||
|
@ -83,6 +83,7 @@ initial_value_pack(struct type **tpp; struct expr **expp;)
|
|||
p_stack = p;
|
||||
}
|
||||
}
|
||||
if (pack_level < gen_error) gen_error = 0;
|
||||
}
|
||||
'}'
|
||||
;
|
||||
|
@ -115,20 +116,20 @@ gen_tpcheck(tpp, union_allowed)
|
|||
switch((tp = *tpp)->tp_fund) {
|
||||
case ARRAY:
|
||||
if (! valid_type(tp->tp_up, "array element"))
|
||||
gen_error = 1;
|
||||
gen_error = pack_level;
|
||||
break;
|
||||
case STRUCT:
|
||||
if (! valid_type(tp, "struct"))
|
||||
gen_error = 1;
|
||||
gen_error = pack_level;
|
||||
break;
|
||||
case UNION:
|
||||
if (! union_allowed) {
|
||||
error("union initialisation not allowed");
|
||||
gen_error = 1;
|
||||
gen_error = pack_level;
|
||||
break;
|
||||
}
|
||||
if (! valid_type(tp, "union"))
|
||||
gen_error = 1;
|
||||
gen_error = pack_level;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +153,7 @@ gen_simple_exp(tpp, expp)
|
|||
check_and_pad(expp, tpp);
|
||||
break;
|
||||
case ERRONEOUS:
|
||||
gen_error = 1;
|
||||
gen_error = pack_level;
|
||||
break;
|
||||
default:
|
||||
check_ival(expp, tp);
|
||||
|
@ -200,7 +201,7 @@ gen_tphead(tpp, nest)
|
|||
register struct sdef *sd;
|
||||
|
||||
if (tpp && *tpp == error_type) {
|
||||
gen_error = 1;
|
||||
gen_error = pack_level;
|
||||
return 0;
|
||||
}
|
||||
if (gen_error) return tpp;
|
||||
|
@ -229,7 +230,7 @@ gen_tphead(tpp, nest)
|
|||
#endif
|
||||
if (! sd) {
|
||||
/* something wrong with this struct */
|
||||
gen_error = 1;
|
||||
gen_error = pack_level;
|
||||
p_stack = p->next;
|
||||
free_e_stack(p);
|
||||
return 0;
|
||||
|
@ -358,7 +359,6 @@ gen_tpend()
|
|||
free_e_stack(p_stack);
|
||||
p_stack = p;
|
||||
}
|
||||
gen_error = 0;
|
||||
}
|
||||
|
||||
/* check_and_pad() is given a simple initialisation expression
|
||||
|
@ -687,12 +687,12 @@ illegal_init_cst(ex)
|
|||
struct expr *ex;
|
||||
{
|
||||
expr_error(ex, "illegal initialisation constant");
|
||||
gen_error = 1;
|
||||
gen_error = pack_level;
|
||||
}
|
||||
|
||||
too_many_initialisers()
|
||||
{
|
||||
error("too many initialisers");
|
||||
gen_error = 1;
|
||||
gen_error = pack_level;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue