(va_arg): Cast argument pointer to (char *).
authorJim Wilson <wilson@gcc.gnu.org>
Wed, 7 Apr 1993 01:33:35 +0000 (18:33 -0700)
committerJim Wilson <wilson@gcc.gnu.org>
Wed, 7 Apr 1993 01:33:35 +0000 (18:33 -0700)
From-SVN: r4039

gcc/ginclude/va-sparc.h

index 02567ef93e54bbcb9b0a9369a4c078604d39b7d9..f3bac34a5603c230c32323d5a42f942d42d1b630 100644 (file)
@@ -64,21 +64,22 @@ void va_end (__gnuc_va_list);               /* Defined in libgcc.a */
 /* We don't declare the union member `d' to have type TYPE
    because that would lose in C++ if TYPE has a constructor.  */
 /* We cast to void * and then to TYPE * because this avoids
-   a warning about increasing the alignment requirement.  */
+   a warning about increasing the alignment requirement.
+   The casts to char * avoid warnings about invalid pointer arithmetic.  */
 #define va_arg(pvar,TYPE)                                      \
 __extension__                                                  \
 ({ TYPE __va_temp;                                             \
    ((__builtin_classify_type (__va_temp) >= 12)                        \
-    ? ((pvar) += __va_rounded_size (TYPE *),                   \
-       **(TYPE **) (void *) ((pvar) - __va_rounded_size (TYPE *))) \
+    ? ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE *),   \
+       **(TYPE **) (void *) ((char *)(pvar) - __va_rounded_size (TYPE *))) \
     : __va_rounded_size (TYPE) == 8                            \
     ? ({ union {char __d[sizeof (TYPE)]; int __i[2];} __u;     \
         __u.__i[0] = ((int *) (void *) (pvar))[0];             \
         __u.__i[1] = ((int *) (void *) (pvar))[1];             \
-        (pvar) += 8;                                           \
+        (pvar) = (char *)(pvar) + 8;                           \
         *(TYPE *) (void *) __u.__d; })                         \
-    : ((pvar) += __va_rounded_size (TYPE),                     \
-       *((TYPE *) (void *) ((pvar) - __va_rounded_size (TYPE)))));})
+    : ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE),     \
+       *((TYPE *) (void *) ((char *)(pvar) - __va_rounded_size (TYPE)))));})
 
 #endif /* defined (_STDARG_H) || defined (_VARARGS_H) */