Fixed 3 bugs
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 18 Feb 2001 01:08:24 +0000 (01:08 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 18 Feb 2001 01:08:24 +0000 (01:08 +0000)
a) constant case label problem (eg -0x01)
b) constant pointer semantics
c) scope of local variables

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@622 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCast.c
src/SDCCsymt.c
src/SDCCsymt.h

index 030946d2aff4ace713eb5b6f26893f7897da2c02..b8e599e0916d2f6710f6a90fd7bc2dbc27080478 100644 (file)
@@ -2213,7 +2213,7 @@ decorateType (ast * tree)
 
 /*------------------------------------------------------------------*/
 /*----------------------------*/
-      /*  address dereference       */
+/*  address dereference       */
 /*----------------------------*/
     case '*':                  /* can be unary  : if right is null then unary operation */
       if (!tree->right)
@@ -2234,7 +2234,7 @@ decorateType (ast * tree)
          TETYPE (tree) = getSpec (TTYPE (tree));
          tree->args = tree->left->args;
          tree->hasVargs = tree->left->hasVargs;
-         SPEC_CONST (TETYPE (tree)) = DCL_PTR_CONST (LTYPE (tree));
+         SPEC_CONST (TETYPE (tree)) = DCL_PTR_CONST (LTYPE(tree));
          return tree;
        }
 
@@ -2387,6 +2387,7 @@ decorateType (ast * tree)
              tree->opval.val = valUnaryPM (valFromType (LETYPE (tree)));
              tree->left = NULL;
              TETYPE (tree) = TTYPE (tree) = tree->opval.val->type;
+             SPEC_USIGN(TETYPE(tree)) = 0;
              return tree;
            }
          LRVAL (tree) = 1;
@@ -2950,9 +2951,11 @@ decorateType (ast * tree)
                               LTYPE (tree));
       RRVAL (tree) = 1;
       LLVAL (tree) = 1;
-      if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
-       werror (E_CODE_WRITE, " ");
-
+      if (!tree->initMode ) {
+             if (IS_CONSTANT (LETYPE (tree))) {
+                     werror (E_CODE_WRITE, " ");
+             } 
+      }
       if (LRVAL (tree))
        {
          werror (E_LVALUE_REQUIRED, "=");
index a537c7053469c6f4346ba39769e5b85fd94fd75c..e5fc5a66e7face3e94dca660fcd2dfa1d3a68741 100644 (file)
@@ -197,7 +197,7 @@ findSymWithLevel (bucket ** stab, symbol * sym)
          if (bp->level && bp->level == sym->level && bp->block == sym->block)
            return (bp->sym);
          /* if levels don't match then we are okay */
-         if (bp->level && bp->level != sym->level)
+         if (bp->level && bp->level != sym->level && bp->block <= sym->block)
            return (bp->sym);
          /* if this is a global variable then we are ok too */
          if (bp->level == 0)
@@ -1785,6 +1785,8 @@ printTypeChain (sym_link * type, FILE * of)
            fprintf (of, "volatile ");
          if (SPEC_USIGN (type))
            fprintf (of, "unsigned ");
+         if (SPEC_CONST (type))
+           fprintf (of, "const ");
 
          switch (SPEC_NOUN (type))
            {
index 172497b16e19ae29ee9ec65f42d5ce2788c0777d..69184e9d257f2e3d37de48bab2860febb51b14b5 100644 (file)
@@ -326,8 +326,7 @@ symbol;
 #define IS_LONG(x)   (IS_SPEC(x) && x->select.s._long)
 #define IS_SHORT(x)   (IS_SPEC(x) && x->select.s._short)
 #define IS_TYPEDEF(x)(IS_SPEC(x) && x->select.s._typedef)
-#define IS_CONSTANT(x)  (IS_SPEC(x) && (x->select.s.sclass == S_CONSTANT ||\
-                                        x->select.s._const == 1))
+#define IS_CONSTANT(x)  (IS_SPEC(x) && ( x->select.s._const == 1))
 #define IS_STRUCT(x) (IS_SPEC(x) && x->select.s.noun == V_STRUCT)
 #define IS_ABSOLUTE(x)  (IS_SPEC(x) && x->select.s._absadr )
 #define IS_REGISTER(x)  (IS_SPEC(x) && SPEC_SCLS(x) == S_REGISTER)