* src/SDCCast.c (decorateType): partial fix for RFE 1475769, remove cast to same...
[fw/sdcc] / src / SDCCast.c
index f240fc9734732895ba3356ea7cfbace397ead992..9a5bf4385365554783452b845fbf267d759880d9 100644 (file)
@@ -3629,6 +3629,13 @@ decorateType (ast * tree, RESULT_TYPE resultType)
       changePointer(LTYPE(tree));
       checkTypeSanity(LETYPE(tree), "(cast)");
 
+      /* if 'from' and 'to' are the same remove the superflous cast, */
+      /* this helps other optimizations */
+      if (compareTypeExact (LTYPE(tree), RTYPE(tree), -1) == 1)
+        {
+          return tree->right;
+        }
+
       /* If code memory is read only, then pointers to code memory */
       /* implicitly point to constants -- make this explicit       */
       {