Warn pointer to signed integer cast for ilp32
[official-gcc.git] / gcc / testsuite / gcc.dg / 20050826-1.c
blobe622505e7da17f65e6e1fa6617bb41158e94e5b2
1 /* Test whether strncmp has not been "optimized" into memcmp
2 nor any code with memcmp semantics. */
3 /* { dg-do run { target mmap } } */
4 /* { dg-options "-O2" } */
5 #include <stddef.h>
6 #include <stdio.h>
7 #include <sys/mman.h>
8 /* Darwin spells this differently */
9 #ifndef MAP_ANONYMOUS
10 #define MAP_ANONYMOUS MAP_ANON
11 #endif
12 #ifndef MAP_ANON
13 #define MAP_ANON 0
14 #endif
15 #include <stdlib.h>
17 struct Flags {
18 int filler[18];
19 unsigned int a:14;
20 unsigned int b:14;
21 unsigned int c:1;
22 unsigned int d:1;
23 unsigned int e:1;
24 unsigned int f:1;
26 static void __attribute__((noinline)) set (struct Flags *);
27 static void set (struct Flags *fp)
29 fp->b = 5;
30 fp->d = 1;
33 static int __attribute__((noinline)) bar (int);
34 static int bar(int x) { return !(x==1); }
35 int main (void)
37 char *p = mmap (NULL, 131072, PROT_READ | PROT_WRITE,
38 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
39 struct Flags *fp;
40 if (p == MAP_FAILED)
41 return 0;
42 if (munmap (p + 65536, 65536) < 0)
43 return 0;
44 fp = (struct Flags*)(p + 65536 - sizeof(struct Flags));
45 set(fp);
46 if (fp->b > 0)
47 return (bar(fp->d));
48 return 1;