* as/mcs51/asdata.c: changed ctype['['] to BINOP
[fw/sdcc] / src / SDCCast.c
index f9183db053285e7fc89127d9bf8fe2e55fa438b2..1d65bc7d783ce2766d4a6901c8f3eedd28854fcb 100644 (file)
@@ -573,7 +573,7 @@ funcOfType (char *name, sym_link * type, sym_link * argType,
     }
 
   /* save it */
-  addSymChain (sym);
+  addSymChain (&sym);
   sym->cdef = 1;
   allocVariables (sym);
   return sym;
@@ -613,7 +613,7 @@ funcOfTypeVarg (char *name, char * rtype, int nArgs , char **atypes)
     }
 
     /* save it */
-    addSymChain (sym);
+    addSymChain (&sym);
     sym->cdef = 1;
     allocVariables (sym);
     return sym;
@@ -1283,7 +1283,7 @@ stringToSymbol (value * val)
   if (noAlloc == 0)
     {
       /* allocate it */
-      addSymChain (sym);
+      addSymChain (&sym);
       allocVariables (sym);
     }
   sym->ival = NULL;
@@ -2098,7 +2098,8 @@ addCast (ast *tree, RESULT_TYPE resultType, bool upcast)
         break;
       case RESULT_TYPE_CHAR:
         if (IS_CHAR (tree->etype) ||
-            IS_FLOAT(tree->etype))
+            IS_FLOAT(tree->etype) ||
+            IS_FIXED(tree->etype))
           return tree;
         newLink = newCharLink();
         break;
@@ -2147,6 +2148,9 @@ resultTypePropagate (ast *tree, RESULT_TYPE resultType)
 {
   switch (tree->opval.op)
     {
+      case AND_OP:
+      case OR_OP:
+        return resultType;
       case '=':
       case '?':
       case ':':
@@ -3401,7 +3405,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
           return tree;
         }
       LRVAL (tree) = 1;
-      TTYPE (tree) = TETYPE (tree) = newCharLink ();
+      TTYPE (tree) = TETYPE (tree) = (resultTypeProp == RESULT_TYPE_BIT) ? newBoolLink() :newCharLink();
       return tree;
 
       /*------------------------------------------------------------------*/
@@ -3416,7 +3420,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
       return tree;
 
     case GETHBIT:
-      TTYPE (tree) = TETYPE (tree) = newCharLink ();
+      TTYPE (tree) = TETYPE (tree) = (resultTypeProp == RESULT_TYPE_BIT) ? newBoolLink() :newCharLink();
       return tree;
 
     case LEFT_OP:
@@ -3581,10 +3585,8 @@ decorateType (ast * tree, RESULT_TYPE resultType)
                 gptype = GPTYPE_FAR;
                 break;
               case S_DATA:
-                gptype = GPTYPE_NEAR;
-                break;
               case S_IDATA:
-                gptype = GPTYPE_IDATA;
+                gptype = GPTYPE_NEAR;
                 break;
               case S_PDATA:
                 gptype = GPTYPE_XSTACK;
@@ -3736,7 +3738,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
           return tree;
         }
       LRVAL (tree) = RRVAL (tree) = 1;
-      TTYPE (tree) = TETYPE (tree) = newCharLink ();
+      TTYPE (tree) = TETYPE (tree) = (resultTypeProp == RESULT_TYPE_BIT) ? newBoolLink() :newCharLink();
       return tree;
 
       /*------------------------------------------------------------------*/
@@ -3879,6 +3881,9 @@ decorateType (ast * tree, RESULT_TYPE resultType)
                 case V_FLOAT:
                     typeofv = TYPEOF_FLOAT;
                     break;
+                case V_FIXED16X16:
+                    typeofv = TYPEOF_FIXED16X16;
+                    break;
                 case V_CHAR:
                     typeofv = TYPEOF_CHAR;
                     break;
@@ -4180,8 +4185,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
         }
 
       /* require a function or pointer to function */
-      if (!IS_FUNC (LTYPE (tree))
-          && !(IS_CODEPTR (LTYPE (tree)) && IS_FUNC (LTYPE (tree)->next)))
+      if (!IS_FUNC (LTYPE (tree)) && !IS_FUNCPTR (LTYPE (tree)))
         {
           werrorfl (tree->filename, tree->lineno, E_FUNCTION_EXPECTED);
           goto errorTreeReturn;
@@ -4195,7 +4199,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
           sym_link *functype;      
           parmNumber = 1;
 
-          if (IS_CODEPTR(LTYPE(tree)))
+          if (IS_FUNCPTR (LTYPE (tree)))
             functype = LTYPE (tree)->next;
           else
             functype = LTYPE (tree);
@@ -5343,7 +5347,7 @@ createFunction (symbol * name, ast * body)
     }
   else
     {
-      addSymChain (name);
+      addSymChain (&name);
       allocVariables (name);
     }
   name->lastLine = mylineno;
@@ -5351,7 +5355,7 @@ createFunction (symbol * name, ast * body)
 
   /* set the stack pointer */
   stackPtr  = -port->stack.direction * port->stack.call_overhead;
-  xstackPtr = -port->stack.direction * port->stack.call_overhead;
+  xstackPtr = 0;
 
   if (IFFUNC_ISISR (name->type))
     stackPtr -= port->stack.direction * port->stack.isr_overhead;