mirror of
https://github.com/frida/tinycc
synced 2024-11-30 19:43:07 +03:00
Fix va_end() definition: must be an expression of type void
Also added a test yielding a failure with the previous definition, i.e. when using: (va_end(ap)); The test also checks potentially incorrect va_start() definition.
This commit is contained in:
parent
920f773a81
commit
be7c870718
@ -25,7 +25,7 @@ void *__va_arg(__va_list_struct *ap, int arg_type, int size, int align);
|
||||
#define va_arg(ap, type) \
|
||||
(*(type *)(__va_arg(ap, __builtin_va_arg_types(type), sizeof(type), __alignof__(type))))
|
||||
#define va_copy(dest, src) (*(dest) = *(src))
|
||||
#define va_end(ap)
|
||||
#define va_end(ap) ((void)0)
|
||||
|
||||
/* avoid conflicting definition for va_list on Macs. */
|
||||
#define _VA_LIST_T
|
||||
@ -36,7 +36,7 @@ typedef char *va_list;
|
||||
#define va_arg(ap, t) ((sizeof(t) > 8 || (sizeof(t) & (sizeof(t) - 1))) \
|
||||
? **(t **)((ap += 8) - 8) : *(t *)((ap += 8) - 8))
|
||||
#define va_copy(dest, src) ((dest) = (src))
|
||||
#define va_end(ap)
|
||||
#define va_end(ap) ((void)0)
|
||||
#endif
|
||||
|
||||
#elif __arm__
|
||||
@ -48,7 +48,7 @@ typedef char *va_list;
|
||||
#define va_arg(ap,type) (ap = (void *) ((_tcc_align(ap,type)+sizeof(type)+3) \
|
||||
&~3), *(type *)(ap - ((sizeof(type)+3)&~3)))
|
||||
#define va_copy(dest, src) (dest) = (src)
|
||||
#define va_end(ap)
|
||||
#define va_end(ap) ((void)0)
|
||||
|
||||
#elif defined(__aarch64__)
|
||||
typedef struct {
|
||||
@ -60,7 +60,7 @@ typedef struct {
|
||||
} va_list;
|
||||
#define va_start(ap, last) __va_start(ap, last)
|
||||
#define va_arg(ap, type) __va_arg(ap, type)
|
||||
#define va_end(ap)
|
||||
#define va_end(ap) ((void)0)
|
||||
#define va_copy(dest, src) ((dest) = (src))
|
||||
|
||||
#else /* __i386__ */
|
||||
@ -69,7 +69,7 @@ typedef char *va_list;
|
||||
#define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3)
|
||||
#define va_arg(ap,type) (ap += (sizeof(type)+3)&~3, *(type *)(ap - ((sizeof(type)+3)&~3)))
|
||||
#define va_copy(dest, src) (dest) = (src)
|
||||
#define va_end(ap)
|
||||
#define va_end(ap) ((void)0)
|
||||
#endif
|
||||
|
||||
/* fix a buggy dependency on GCC in libio.h */
|
||||
|
@ -2622,6 +2622,19 @@ void stdarg_for_libc(const char *fmt, ...)
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void stdarg_syntax(int n, ...)
|
||||
{
|
||||
int i;
|
||||
va_list ap;
|
||||
if (1)
|
||||
va_start(ap, n);
|
||||
else
|
||||
;
|
||||
i = va_arg(ap, int);
|
||||
printf("stdarg_void_expr: %d\n", i);
|
||||
(va_end(ap));
|
||||
}
|
||||
|
||||
void stdarg_test(void)
|
||||
{
|
||||
LONG_DOUBLE ld = 1234567891234LL;
|
||||
@ -2669,6 +2682,7 @@ void stdarg_test(void)
|
||||
bob.profile = 42;
|
||||
stdarg_for_struct(bob, bob, bob, bob.profile);
|
||||
stdarg_for_libc("stdarg_for_libc: %s %.2f %d\n", "string", 1.23, 456);
|
||||
stdarg_syntax(1, 17);
|
||||
}
|
||||
|
||||
void whitespace_test(void)
|
||||
|
Loading…
Reference in New Issue
Block a user