a better fix for "if ( -v < 3)"
[fw/sdcc] / src / SDCCast.c
index 0962481a8c8aaf5cc23b165b3ca6c1a1f18e77f7..644d8fb3ddbafd082976f2cbc064cd712227a11d 100644 (file)
@@ -1211,14 +1211,14 @@ processBlockVars (ast * tree, int *stack, int action)
       ast *autoInit;
 
       if (action == ALLOCATE)
-       {
+        {
          *stack += allocVariables (tree->values.sym);
          autoInit = gatherAutoInit (tree->values.sym);
-
+       
          /* if there are auto inits then do them */
          if (autoInit)
            tree->left = newNode (NULLOP, autoInit, tree->left);
-       }
+        }
       else                     /* action is deallocate */
        deallocLocal (tree->values.sym);
     }
@@ -1275,7 +1275,7 @@ bool constExprTree (ast *cexpr) {
        return constExprTree(cexpr->right);
       }
       if (cexpr->opval.op==CAST) {
-       // jwk: cast ignored, maybe we should throw a warning here
+       // cast ignored, maybe we should throw a warning here?
        return constExprTree(cexpr->right);
       }
       if (cexpr->opval.op=='&') { 
@@ -2144,7 +2144,7 @@ decorateType (ast * tree)
       {
        sym_link *ltc = (tree->right ? RTYPE (tree) : LTYPE (tree));
        COPYTYPE (TTYPE (tree), TETYPE (tree), ltc);
-       if (!tree->initMode && IS_CONSTANT (TTYPE (tree)))
+       if (!tree->initMode && IS_CONSTANT(TETYPE(tree)))
          werror (E_CODE_WRITE, tree->opval.op==INC_OP ? "++" : "--");
 
        if (tree->right)
@@ -2563,7 +2563,7 @@ decorateType (ast * tree)
              return tree;
            }
          LRVAL (tree) = 1;
-         TTYPE (tree) = LTYPE (tree);
+         TETYPE(tree) = getSpec (TTYPE (tree) = LTYPE (tree));
          return tree;
        }
 
@@ -2930,7 +2930,7 @@ decorateType (ast * tree)
        }
       /* if unsigned value < 0  then always false */
       /* if (unsigned value) > 0 then (unsigned value) */
-      if (SPEC_USIGN(LETYPE(tree)) && IS_LITERAL(RTYPE(tree)) && 
+      if (SPEC_USIGN(LETYPE(tree)) && IS_LITERAL(RTYPE(tree))  && 
          ((int) floatFromVal (valFromType (RETYPE (tree)))) == 0) {
 
          if (tree->opval.op == '<') {
@@ -3124,7 +3124,7 @@ decorateType (ast * tree)
       RRVAL (tree) = 1;
       TETYPE (tree) = getSpec (TTYPE (tree) = LTYPE (tree));
 
-      if (!tree->initMode && IS_CONSTANT (LTYPE (tree)))
+      if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
        werror (E_CODE_WRITE, "&= or |= or ^= or >>= or <<=");
 
       if (LRVAL (tree))
@@ -3159,7 +3159,7 @@ decorateType (ast * tree)
                               computeType (LTYPE (tree),
                                            RTYPE (tree)));
 
-      if (!tree->initMode && IS_CONSTANT (LTYPE (tree)))
+      if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
        werror (E_CODE_WRITE, "-=");
 
       if (LRVAL (tree))
@@ -3200,7 +3200,7 @@ decorateType (ast * tree)
                               computeType (LTYPE (tree),
                                            RTYPE (tree)));
 
-      if (!tree->initMode && IS_CONSTANT (LTYPE (tree)))
+      if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
        werror (E_CODE_WRITE, "+=");
 
       if (LRVAL (tree))
@@ -3248,7 +3248,7 @@ decorateType (ast * tree)
       RRVAL (tree) = 1;
       LLVAL (tree) = 1;
       if (!tree->initMode ) {
-       if (IS_CONSTANT (LTYPE (tree)))
+       if ((IS_SPEC(LETYPE(tree)) && IS_CONSTANT (LETYPE (tree))))
          werror (E_CODE_WRITE, "=");
       }
       if (LRVAL (tree))
@@ -3540,12 +3540,12 @@ createBlock (symbol * decl, ast * body)
   ast *ex;
 
   /* if the block has nothing */
-  if (!body)
+  if (!body && !decl)
     return NULL;
 
   ex = newNode (BLOCK, NULL, body);
   ex->values.sym = decl;
-
+  
   ex->right = ex->right;
   ex->level++;
   ex->lineno = 0;
@@ -4397,6 +4397,7 @@ skipall:
 
   /* dealloc the block variables */
   processBlockVars (body, &stack, DEALLOCATE);
+  outputDebugStackSymbols();
   /* deallocate paramaters */
   deallocParms (FUNC_ARGS(name->type));
 
@@ -4411,8 +4412,8 @@ skipall:
   addSet (&operKeyReset, name);
   applyToSet (operKeyReset, resetParmKey);
 
-  if (options.debug)
-    cdbStructBlock (1, cdbFile);
+  if (options.debug)    
+    cdbStructBlock(1);
 
   cleanUpLevel (LabelTab, 0);
   cleanUpBlock (StructTab, 1);