added use checking for types and constants, improved overflow checking
authorceriel <none@none>
Fri, 27 Nov 1987 14:24:46 +0000 (14:24 +0000)
committerceriel <none@none>
Fri, 27 Nov 1987 14:24:46 +0000 (14:24 +0000)
lang/m2/comp/LLlex.c
lang/m2/comp/def.c
lang/m2/comp/enter.c
lang/m2/comp/scope.C
lang/m2/comp/type.c
lang/m2/comp/walk.c

index 4d48ebd..2b09703 100644 (file)
@@ -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;
                                }
 
index 5f2e8f5..e8d10c1 100644 (file)
@@ -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
        */
index 10e47f4..b2651fd 100644 (file)
@@ -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
                        */
index 6b4a91c..1ebc911 100644 (file)
@@ -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;
index 663efc1..539d1da 100644 (file)
@@ -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;
index 7961ec7..0c23bf7 100644 (file)
@@ -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,