| 1 |
/* Test there is no ICE when compile. */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
|
| 4 |
#define PRINTF_CHK 0x34 |
| 5 |
|
| 6 |
typedef __UINTPTR_TYPE__ uintptr_t; |
| 7 |
|
| 8 |
struct __printf_buffer { |
| 9 |
char *write_ptr; |
| 10 |
int status; |
| 11 |
}; |
| 12 |
|
| 13 |
extern void __printf_buffer_init_end (struct __printf_buffer *, char *, char *); |
| 14 |
|
| 15 |
void |
| 16 |
test (char *string, unsigned long maxlen, unsigned mode_flags) |
| 17 |
{ |
| 18 |
struct __printf_buffer buf; |
| 19 |
|
| 20 |
if ((mode_flags & PRINTF_CHK) != 0) |
| 21 |
{ |
| 22 |
string[0] = '\0'; |
| 23 |
uintptr_t end; |
| 24 |
|
| 25 |
if (__builtin_add_overflow ((uintptr_t) string, maxlen, &end)) |
| 26 |
end = -1; |
| 27 |
|
| 28 |
__printf_buffer_init_end (&buf, string, (char *) end); |
| 29 |
} |
| 30 |
else |
| 31 |
__printf_buffer_init_end (&buf, string, (char *) ~(uintptr_t) 0); |
| 32 |
|
| 33 |
*buf.write_ptr = '\0'; |
| 34 |
} |