* src/SDCCast.c, src/SDCCast.h: fixed bug #1874922: explicit typecast
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 24 Feb 2008 20:59:03 +0000 (20:59 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 24 Feb 2008 20:59:03 +0000 (20:59 +0000)
  is ineffective for unsigned char parameter

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

ChangeLog
src/SDCCast.c
src/SDCCast.h

index c6ed9cd413aa93ccfb47f44fc495ab961ad31be9..23c5409514d7d719ad62dd8841256df7d90188c0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-02-24 Borut Razem <borut.razem AT siol.net>
+
+       * src/SDCCast.c, src/SDCCast.h: fixed bug #1874922: explicit typecast
+         is ineffective for unsigned char parameter
+
 2008-02-24 Maarten Brock <sourceforge.brock AT dse.nl>
 
        * src/SDCCast.c (expandInlineFuncs): fixed bug 1875869
 2008-02-22 Philipp Klaus Krause <pkk AT spth.de>
 
        * src/z80/gen.c (genMult): Rewrote 8-bit multiplication by constant,
-          implements #1898231
+         implements #1898231
 
 2008-02-22 Philipp Klaus Krause <pkk AT spth.de>
 
        * device/lib/z80/mul.s: Rewrote __muluchar_rrx_s, to improve 8-bit mult.,
-          implements #1896290
+         implements #1896290
 
 2008-02-22 Maarten Brock <sourceforge.brock AT dse.nl>
 
index 2fd8318631ba7ba7967b58fe13b53ec506e6d055..24c3eb1c9daa14ad523906f5a1df9aadd7597ad8 100644 (file)
@@ -227,6 +227,7 @@ copyAst (ast * src)
   dest->level = src->level;
   dest->funcName = src->funcName;
   dest->reversed = src->reversed;
+  dest->actualArgument = src->actualArgument;
 
   if (src->ftype)
     dest->etype = getSpec (dest->ftype = copyLinkChain (src->ftype));
@@ -837,6 +838,9 @@ processParms (ast *func,
         }
     }
 
+  /* mark the actual parameter */
+  (*actParm)->actualArgument = 1;
+
   /* decorate parameter */
   resultType = defParm ? getResultTypeFromType (defParm->type) :
                          RESULT_TYPE_NONE;
@@ -854,8 +858,11 @@ processParms (ast *func,
       ast *newType = NULL;
       sym_link *ftype;
 
+      int isCast = IS_CAST_OP (*actParm);
+      int isAstLitValue = (IS_AST_LIT_VALUE (*actParm));
+
       if (IS_CAST_OP (*actParm)
-          || (IS_AST_LIT_VALUE (*actParm) && (*actParm)->values.literalFromCast))
+        || (IS_AST_LIT_VALUE (*actParm) && (*actParm)->values.literalFromCast))
         {
           /* Parameter was explicitly typecast; don't touch it. */
           return 0;
@@ -3834,9 +3841,11 @@ decorateType (ast * tree, RESULT_TYPE resultType)
       changePointer(LTYPE(tree));
       checkTypeSanity(LETYPE(tree), "(cast)");
 
-      /* if 'from' and 'to' are the same remove the superfluous cast, */
-      /* this helps other optimizations */
-      if (compareTypeExact (LTYPE(tree), RTYPE(tree), -1) == 1)
+
+      /* if not an actual argument and
+       * if 'from' and 'to' are the same remove the superfluous cast,
+       * this helps other optimizations */
+      if (!tree->actualArgument && compareTypeExact (LTYPE(tree), RTYPE(tree), -1) == 1)
         {
           return tree->right;
         }
@@ -4153,9 +4162,7 @@ decorateType (ast * tree, RESULT_TYPE resultType)
                 if (!options.lessPedantic)
                   werrorfl (tree->filename, tree->lineno, W_COMP_RANGE,
                           ccr_result == CCR_ALWAYS_TRUE ? "true" : "false");
-                return decorateType (newAst_VALUE (constCharVal (
-                                   (unsigned char)(ccr_result == CCR_ALWAYS_TRUE ? 1 : 0))),
-                                                   resultType);
+                return decorateType (newAst_VALUE (constCharVal ((unsigned char)(ccr_result == CCR_ALWAYS_TRUE))), resultType);
               case CCR_OK:
               default:
                 break;
@@ -6306,7 +6313,7 @@ expandInlineFuncs (ast * tree, ast * block)
               ast * assigntree;
               symbol * parm;
               ast * passedarg = inlineFindParm (tree->right, argIndex);
-              
+
               if (!passedarg)
                 {
                   werror(E_TOO_FEW_PARMS);
index 3b8ec6e1fdd7d826fccf5b681ae6c6012a41cf0f..3bf42291123d73e0380bd92fb2f2fcafb678422a 100644 (file)
@@ -50,6 +50,7 @@ typedef struct ast
     unsigned lvalue:1;
     unsigned initMode:1;
     unsigned reversed:1;
+    unsigned actualArgument:1;  /* actual function argument */
     int level;                  /* level for expr */
     int block;                  /* block number   */
     int seqPoint;               /* sequence point */