Warn pointer to signed integer cast for ilp32
[official-gcc.git] / gcc / testsuite / gcc.dg / setjmp-2.c
blobf31f6b2926847a4e9e992f13fbb6ca187538e075
1 /* PR middle-end/17813 */
2 /* Origin: Tom Hughes <tom@compton.nu> */
3 /* { dg-do run { target i?86-*-linux* x86_64-*-linux* } } */
4 /* { dg-options "-O -fomit-frame-pointer" } */
5 /* { dg-options "-O -fomit-frame-pointer -march=i386" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
7 #include <setjmp.h>
8 #include <signal.h>
9 #include <stdlib.h>
11 static jmp_buf segv_jmpbuf;
13 static void segv_handler(int seg)
15 __builtin_longjmp(segv_jmpbuf, 1);
18 static int is_addressable(void *p, size_t size)
20 volatile char * volatile cp = (volatile char *)p;
21 volatile int ret;
22 struct sigaction sa, origsa;
23 sigset_t mask;
25 sa.sa_handler = segv_handler;
26 sa.sa_flags = 0;
27 sigfillset(&sa.sa_mask);
28 sigaction(SIGSEGV, &sa, &origsa);
29 sigprocmask(SIG_SETMASK, NULL, &mask);
31 if (__builtin_setjmp(segv_jmpbuf) == 0) {
32 while(size--)
33 *cp++;
34 ret = 1;
35 } else
36 ret = 0;
38 sigaction(SIGSEGV, &origsa, NULL);
39 sigprocmask(SIG_SETMASK, &mask, NULL);
41 return ret;
44 int main(int argc, char **argv)
46 is_addressable(0x0, 1);
47 return 0;