]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.dg/pr65408.c
Update copyright years.
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / pr65408.c
CommitLineData
984b2054
AM
1/* PR middle-end/36043 target/58744 target/65408 */
2/* { dg-do run { target mmap } } */
3/* { dg-options "-O2" } */
4
5#include <sys/mman.h>
6#ifndef MAP_ANONYMOUS
7#define MAP_ANONYMOUS MAP_ANON
8#endif
9#ifndef MAP_ANON
10#define MAP_ANON 0
11#endif
12#ifndef MAP_FAILED
13#define MAP_FAILED ((void *)-1)
14#endif
15
16typedef struct
17{
18 unsigned char r;
19 unsigned char g;
20 unsigned char b;
21} __attribute__((packed)) pr58744;
22
23typedef struct
24{
25 unsigned short r;
26 unsigned short g;
27 unsigned short b;
28} pr36043;
29
30typedef struct
31{
32 int r;
33 int g;
34 int b;
35} pr65408;
36
37__attribute__ ((noinline, noclone))
38void
39f1a (pr58744 x)
40{
41 if (x.r != 1 || x.g != 2 || x.b != 3)
42 __builtin_abort();
43}
44
45__attribute__ ((noinline, noclone))
46void
47f1 (pr58744 *x)
48{
49 f1a (*x);
50}
51
52__attribute__ ((noinline, noclone))
53void
54f2a (pr36043 x)
55{
56 if (x.r != 1 || x.g != 2 || x.b != 3)
57 __builtin_abort();
58}
59
60__attribute__ ((noinline, noclone))
61void
62f2 (pr36043 *x)
63{
64 f2a (*x);
65}
66
67__attribute__ ((noinline, noclone))
68void
69f3a (pr65408 x)
70{
71 if (x.r != 1 || x.g != 2 || x.b != 3)
72 __builtin_abort();
73}
74
75__attribute__ ((noinline, noclone))
76void
77f3 (pr65408 *x)
78{
79 f3a (*x);
80}
81
82int
83main ()
84{
85 char *p = mmap ((void *) 0, 131072, PROT_READ | PROT_WRITE,
86 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
87 if (p == MAP_FAILED)
88 return 0;
89 char *endp = p + 65536;
90 if (munmap (endp, 65536) < 0)
91 return 0;
92
93 pr58744 *s1 = (pr58744 *) endp - 1;
94 s1->r = 1;
95 s1->g = 2;
96 s1->b = 3;
97 f1 (s1);
98
99 pr36043 *s2 = (pr36043 *) endp - 1;
100 s2->r = 1;
101 s2->g = 2;
102 s2->b = 3;
103 f2 (s2);
104
105 pr65408 *s3 = (pr65408 *) endp - 1;
106 s3->r = 1;
107 s3->g = 2;
108 s3->b = 3;
109 f3 (s3);
110
111 return 0;
112}