(va_arg): Cast ptr to void *, then to TYPE *.
authorRichard Stallman <rms@gnu.org>
Tue, 15 Sep 1992 05:08:02 +0000 (05:08 +0000)
committerRichard Stallman <rms@gnu.org>
Tue, 15 Sep 1992 05:08:02 +0000 (05:08 +0000)
From-SVN: r2124

gcc/ginclude/stdarg.h
gcc/ginclude/va-i960.h
gcc/ginclude/va-m88k.h
gcc/ginclude/va-mips.h
gcc/ginclude/va-pa.h
gcc/ginclude/va-pyr.h
gcc/ginclude/va-sparc.h

index 79fe404d5ea71cfa2147b366f2d74f752b539837..ee9204ab4e993f0fed0479a323e79fb0bf6a225b 100644 (file)
@@ -62,9 +62,11 @@ typedef void *__gnuc_va_list;
 void va_end (__gnuc_va_list);          /* Defined in libgcc.a */
 #define va_end(AP)
 
+/* We cast to void * and then to TYPE * because this avoids
+   a warning about increasing the alignment requirement.  */
 #define va_arg(AP, TYPE)                                               \
  (AP = (char *) (AP) + __va_rounded_size (TYPE),                       \
-  *((TYPE *) ((char *) (AP) - __va_rounded_size (TYPE))))
+  *((TYPE *) (void *) ((char *) (AP) - __va_rounded_size (TYPE))))
 #endif /* _STDARG_H */
 
 #endif /* not alpha */
index 28fc0d44935b68206cc9f63e9ee80ace5d13ed74..549e9fec1aed694ae696e57f7d36ca1492080824 100644 (file)
@@ -40,6 +40,8 @@ typedef unsigned __gnuc_va_list[2];
 #define        va_start(AP) ((AP)[1] = 0, *(AP) = (unsigned) &va_alist)
 #endif
 
+/* We cast to void * and then to TYPE * because this avoids
+   a warning about increasing the alignment requirement.  */
 #define        va_arg(AP, T)                                                   \
 (                                                                      \
   (                                                                    \
@@ -48,7 +50,7 @@ typedef unsigned __gnuc_va_list[2];
       : ((AP)[1] = __vpad ((AP)[1], T))                                        \
   ),                                                                   \
                                                                        \
-  *((T *) ((char *) *(AP) + (AP)[1] - __vsiz (T)))                     \
+  *((T *) (void *) ((char *) *(AP) + (AP)[1] - __vsiz (T)))            \
 )
 
 void va_end (__gnuc_va_list);          /* Defined in libgcc.a */
index 5c7b10ec84d9f0c8a52b42f60ed6119179eb4868..ae1d4d64fc49196ef67c18e340eb3af2d3305883 100644 (file)
@@ -63,13 +63,16 @@ typedef struct
 
 #define        __va_size(TYPE) ((sizeof(TYPE) + 3) >> 2)
 
-#define va_arg(AP,TYPE) \
+/* We cast to void * and then to TYPE * because this avoids
+   a warning about increasing the alignment requirement.  */
+#define va_arg(AP,TYPE)                                                           \
   ( (AP).__va_arg = (((AP).__va_arg + (1 << (__alignof__(TYPE) >> 3)) - 1) \
-                    & ~((1 << (__alignof__(TYPE) >> 3)) - 1)) \
-    + __va_size(TYPE), \
-    *((TYPE *) ((__va_reg_p(TYPE) && (AP).__va_arg < 8 + __va_size(TYPE) \
-                ? (AP).__va_reg : (AP).__va_stk) \
-               + ((AP).__va_arg - __va_size(TYPE)))))
+                    & ~((1 << (__alignof__(TYPE) >> 3)) - 1))             \
+    + __va_size(TYPE),                                                    \
+    *((TYPE *) (void *) ((__va_reg_p(TYPE)                                \
+                         && (AP).__va_arg < 8 + __va_size(TYPE)           \
+                         ? (AP).__va_reg : (AP).__va_stk)                 \
+                        + ((AP).__va_arg - __va_size(TYPE)))))
 
 #define va_end(AP)
 
index 4222f8bf203262d52b881097ec04e185ca91f4f9..ec0e7803475eb648591db07f7bd89bbe7436874f 100644 (file)
@@ -49,11 +49,13 @@ void va_end (__gnuc_va_list);               /* Defined in libgcc.a */
 #define va_arg(list, mode) ((mode *)(list += __va_rounded_size(mode)))[-1]
 
 #else          /* !lint */
-#define va_arg(__AP, __type)                                           \
-  ((__type *)(__AP = (char *) ((__alignof(__type) > 4                  \
-                               ? ((int)__AP + 8 - 1) & -8              \
-                               : ((int)__AP + 4 - 1) & -4)             \
-                          + __va_rounded_size(__type))))[-1]
+/* We cast to void * and then to TYPE * because this avoids
+   a warning about increasing the alignment requirement.  */
+#define va_arg(__AP, __type)                                               \
+  ((__type *) (void *) (__AP = (char *) ((__alignof(__type) > 4                    \
+                                         ? ((int)__AP + 8 - 1) & -8        \
+                                         : ((int)__AP + 4 - 1) & -4)       \
+                                        + __va_rounded_size(__type))))[-1]
 #endif         /* lint */
 
 #endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
index 0d84ef7ae860f9a9d9b39f4f0de37f2cdc8aaa0d..eb6c600fab9abd51e8539c3c7fc1b3c2c12acf57 100644 (file)
@@ -22,11 +22,11 @@ typedef double *__gnuc_va_list;
 #define va_arg(AP,TYPE)                                                \
   (sizeof(TYPE) > 8 ?                                          \
    ((AP = (__gnuc_va_list) ((char *)AP - sizeof (int))),       \
-    (*((TYPE *) (*((int *) (AP))))))                           \
+    (*((TYPE *) (void *) (*((int *) (AP))))))                  \
    :((AP =                                                     \
       (__gnuc_va_list) ((long)((char *)AP - sizeof (TYPE))     \
                        & (sizeof(TYPE) > 4 ? ~0x7 : ~0x3))),   \
-     (*((TYPE *) ((char *)AP + ((8 - sizeof(TYPE)) % 4))))))
+     (*((TYPE *) (void *) ((char *)AP + ((8 - sizeof(TYPE)) % 4))))))
 
 #define va_end(AP)
 
index 61bddbf60c8fb68e89a37f97cf9053442ce3cbc8..86f3715e9d0afe09d10ed02b38f99d59501f950f 100644 (file)
@@ -107,6 +107,8 @@ typedef __va_buf __gnuc_va_list;
 #define __extension__
 #endif
 
+/* We cast to void * and then to TYPE * because this avoids
+   a warning about increasing the alignment requirement.  */
 #define va_arg(_AP, _MODE)     \
 __extension__                                                          \
 ({__voidptr *__ap = (__voidptr*)&_AP;                                  \
@@ -119,7 +121,7 @@ __extension__                                                               \
   ((void *)__ap[__onstack])+=__size;                                   \
     if (__onstack==0 || (int)(__ap[2])==11)                            \
       __ap[2]+= (__size >> 2);                                         \
-  *(( _MODE *)__param_addr);                                           \
+  *(( _MODE *) (void *) __param_addr);                                 \
 })
 
 void va_end (__gnuc_va_list);          /* Defined in libgcc.a */
index f98bbc4fd440f46708537a75ef5e1d16cd2ab4f1..2744c4321b9dd80666364b0f473327023e07db0e 100644 (file)
@@ -59,6 +59,8 @@ void va_end (__gnuc_va_list);         /* Defined in libgcc.a */
    not word-aligned, we advance the pointer to the first non-reg slot.  */
 /* 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.  */
 #define va_arg(pvar,TYPE)                                      \
 __extension__                                                  \
 ({ TYPE __va_temp;                                             \
@@ -70,9 +72,9 @@ __extension__                                                 \
         __u.__i[0] = ((int *) (pvar))[0];                      \
         __u.__i[1] = ((int *) (pvar))[1];                      \
         (pvar) += 8;                                           \
-        *(TYPE *)__u.__d; })                                   \
+        *(TYPE *) (void *) __u.__d; })                         \
     : ((pvar) += __va_rounded_size (TYPE),                     \
-       *((TYPE *) ((pvar) - __va_rounded_size (TYPE)))));})
+       *((TYPE *) (void *) ((pvar) - __va_rounded_size (TYPE)))));})
 
 #endif /* defined (_STDARG_H) || defined (_VARARGS_H) */