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