added use checking for types and constants, improved overflow checking
This commit is contained in:
parent
3e51d4f62f
commit
3627b9a16c
|
@ -493,7 +493,8 @@ lexwarning(W_ORDINARY, "character constant out of range");
|
|||
}
|
||||
}
|
||||
else if (ch == 'D' && base == 10) {
|
||||
if (sgnswtch != 0) {
|
||||
if (sgnswtch != 0 ||
|
||||
tk->TOK_INT > max_int[(int)long_size]) {
|
||||
lexwarning(W_ORDINARY, "overflow in constant");
|
||||
}
|
||||
toktype = longint_type;
|
||||
|
@ -502,6 +503,11 @@ lexwarning(W_ORDINARY, "overflow in constant");
|
|||
tk->TOK_INT<=max_int[(int)word_size]) {
|
||||
toktype = intorcard_type;
|
||||
}
|
||||
else if (! chk_bounds(tk->TOK_INT,
|
||||
full_mask[(int)word_size],
|
||||
T_CARDINAL)) {
|
||||
lexwarning(W_ORDINARY, "overflow in constant");
|
||||
}
|
||||
return tk->tk_symb = INTEGER;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,9 @@ MkDef(id, scope, kind)
|
|||
df->df_next = id->id_def;
|
||||
id->id_def = df;
|
||||
if (kind == D_ERROR || kind == D_FORWARD) df->df_type = error_type;
|
||||
if (kind & (D_TYPE|D_PROCEDURE|D_CONST)) {
|
||||
df->df_flags = D_DEFINED;
|
||||
}
|
||||
|
||||
/* enter the definition in the list of definitions in this scope
|
||||
*/
|
||||
|
|
|
@ -129,7 +129,6 @@ EnterVarList(Idlist, type, local)
|
|||
for (; idlist; idlist = idlist->nd_right) {
|
||||
df = define(idlist->nd_IDF, CurrentScope, D_VARIABLE);
|
||||
df->df_type = type;
|
||||
/* df->df_flags &= ~(D_USED | D_DEFINED); */
|
||||
if (idlist->nd_left) {
|
||||
/* An address was supplied
|
||||
*/
|
||||
|
|
|
@ -187,7 +187,7 @@ Reverse(pdf)
|
|||
from this list.
|
||||
*/
|
||||
register t_def *df, *df1;
|
||||
#define INTERESTING (D_MODULE|D_PROCEDURE|D_PROCHEAD|D_VARIABLE|D_IMPORTED)
|
||||
#define INTERESTING (D_MODULE|D_PROCEDURE|D_PROCHEAD|D_VARIABLE|D_IMPORTED|D_TYPE|D_CONST)
|
||||
|
||||
df = 0;
|
||||
df1 = *pdf;
|
||||
|
|
|
@ -659,6 +659,7 @@ type_or_forward(ptp)
|
|||
same scope.
|
||||
*/
|
||||
df = define(nd->nd_IDF, CurrentScope, D_FORWTYPE);
|
||||
df->df_flags |= D_USED | D_DEFINED;
|
||||
|
||||
if (df->df_kind == D_TYPE) {
|
||||
(*ptp)->tp_next = df->df_type;
|
||||
|
|
|
@ -858,7 +858,7 @@ UseWarnings(df)
|
|||
register t_def *df;
|
||||
{
|
||||
if (is_anon_idf(df->df_idf)) return;
|
||||
if (df->df_kind & (D_IMPORTED | D_VARIABLE | D_PROCEDURE)) {
|
||||
if (df->df_kind & (D_IMPORTED | D_VARIABLE | D_PROCEDURE | D_CONST | D_TYPE)) {
|
||||
struct node *nd;
|
||||
|
||||
if (df->df_flags & (D_EXPORTED | D_QEXPORTED)) return;
|
||||
|
@ -879,7 +879,7 @@ UseWarnings(df)
|
|||
}
|
||||
df = df1;
|
||||
}
|
||||
if (! (df->df_kind & (D_VARIABLE|D_PROCEDURE))) return;
|
||||
if (! (df->df_kind & (D_VARIABLE|D_PROCEDURE|D_TYPE|D_CONST))) return;
|
||||
nd = df->df_scope->sc_end;
|
||||
if (! (df->df_flags & D_DEFINED)) {
|
||||
node_warning(nd,
|
||||
|
|
Loading…
Reference in a new issue