]> git.sur5r.net Git - cc65/commitdiff
Fix 32/64-bit int/pointer casts
authorBas Wassink <b.wassink@ziggo.nl>
Sat, 23 Mar 2019 00:14:04 +0000 (01:14 +0100)
committerBas Wassink <b.wassink@ziggo.nl>
Sat, 23 Mar 2019 00:14:04 +0000 (01:14 +0100)
src/cc65/locals.c
src/cc65/symtab.c

index 36afb6223897b7be1eaad7e072ba659fd98555f1..024c1c5fc457344f559ced2e3da1964939c2b85b 100644 (file)
@@ -275,8 +275,9 @@ static void ParseAutoDecl (Declaration* Decl)
             ** We abuse the Collection somewhat by using it to store line
             ** numbers.
             */
-            CollReplace (&CurrentFunc->LocalsBlockStack, (void *)(long)GetCurrentLine (),
-                CollCount (&CurrentFunc->LocalsBlockStack) - 1);
+            CollReplace (&CurrentFunc->LocalsBlockStack,
+                    (void *)(size_t)GetCurrentLine (),
+                    CollCount (&CurrentFunc->LocalsBlockStack) - 1);
 
         } else {
             /* Non-initialized local variable. Just keep track of
index 9eb0346e8bdae0ecb9789a8276ec4356a897a0f8..bdbec55bb27cbf4fddcb87d2aaa9d5c1cf0b28b9 100644 (file)
@@ -671,7 +671,7 @@ DefOrRef* AddDefOrRef (SymEntry* E, unsigned Flags)
     DOR = xmalloc (sizeof (DefOrRef));
     CollAppend (E->V.L.DefsOrRefs, DOR);
     DOR->Line = GetCurrentLine ();
-    DOR->LocalsBlockId = (long)CollLast (&CurrentFunc->LocalsBlockStack);
+    DOR->LocalsBlockId = (ssize_t)CollLast (&CurrentFunc->LocalsBlockStack);
     DOR->Flags = Flags;
     DOR->StackPtr = StackPtr;
     DOR->Depth = CollCount (&CurrentFunc->LocalsBlockStack);
@@ -729,9 +729,9 @@ SymEntry* AddLabelSym (const char* Name, unsigned Flags)
                 /* Are we jumping into a block with initalization of an object that
                 ** has automatic storage duration? Let's emit a warning.
                 */
-                if ((long)CollLast (AIC) != DOR->LocalsBlockId &&
+                if ((size_t)CollLast (AIC) != (size_t)(DOR->LocalsBlockId) &&
                     (CollCount (AIC) < DOR->Depth ||
-                    (long)CollAt (AIC, DOR->Depth - 1) != DOR->LocalsBlockId)) {
+                    (size_t)CollAt (AIC, DOR->Depth - 1) != DOR->LocalsBlockId)) {
                     Warning ("Goto at line %d to label %s jumps into a block with "
                     "initialization of an object that has automatic storage duration",
                     GetCurrentLine (), Name);
@@ -758,9 +758,9 @@ SymEntry* AddLabelSym (const char* Name, unsigned Flags)
                 /* Are we jumping into a block with initalization of an object that
                 ** has automatic storage duration? Let's emit a warning.
                 */
-                if ((long)CollLast (AIC) != DOR->LocalsBlockId &&
+                if ((ssize_t)CollLast (AIC) != DOR->LocalsBlockId &&
                     (CollCount (AIC) >= DOR->Depth ||
-                    (long)CollLast (AIC) >= (long)DOR->Line))
+                    (ssize_t)CollLast (AIC) >= (long)DOR->Line))
                     Warning ("Goto at line %d to label %s jumps into a block with "
                     "initialization of an object that has automatic storage duration",
                     DOR->Line, Name);