libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / pr53703.c
blob5188c48d906252614a359f3acef3bd666c9d1262
1 /* Reduced test case from PR53703. Used to ICE. */
3 /* { dg-do compile } */
4 /* { dg-options "-w" } */
6 typedef long unsigned int size_t;
7 typedef unsigned short int sa_family_t;
8 struct sockaddr {};
9 typedef unsigned char __u8;
10 typedef unsigned short __u16;
11 typedef unsigned int __u32;
12 struct nlmsghdr {
13 __u32 nlmsg_len;
14 __u16 nlmsg_type;
16 struct ifaddrmsg {
17 __u8 ifa_family;
19 enum {
20 IFA_ADDRESS,
21 IFA_LOCAL,
23 enum {
24 RTM_NEWLINK = 16,
25 RTM_NEWADDR = 20,
27 struct rtattr {
28 unsigned short rta_len;
29 unsigned short rta_type;
31 struct ifaddrs {
32 struct ifaddrs *ifa_next;
33 unsigned short ifa_flags;
35 typedef unsigned short int uint16_t;
36 typedef unsigned int uint32_t;
37 struct nlmsg_list {
38 struct nlmsg_list *nlm_next;
39 int size;
41 struct rtmaddr_ifamap {
42 void *address;
43 void *local;
44 int address_len;
45 int local_len;
47 int ifa_sa_len (int, int);
48 int usagi_getifaddrs (struct ifaddrs **ifap)
50 struct nlmsg_list *nlmsg_list, *nlmsg_end, *nlm;
51 size_t dlen, xlen, nlen;
52 int build;
53 for (build = 0; build <= 1; build++)
55 struct ifaddrs *ifl = ((void *)0), *ifa = ((void *)0);
56 struct nlmsghdr *nlh, *nlh0;
57 uint16_t *ifflist = ((void *)0);
58 struct rtmaddr_ifamap ifamap;
59 for (nlm = nlmsg_list; nlm; nlm = nlm->nlm_next)
61 int nlmlen = nlm->size;
62 for (nlh = nlh0;
63 ((nlmlen) >= (int)sizeof(struct nlmsghdr)
64 && (nlh)->nlmsg_len >= sizeof(struct nlmsghdr)
65 && (nlh)->nlmsg_len <= (nlmlen));
66 nlh = ((nlmlen) -= ( (((nlh)->nlmsg_len)+4U -1) & ~(4U -1) ),
67 (struct nlmsghdr*)(((char*)(nlh))
68 + ( (((nlh)->nlmsg_len)+4U -1)
69 & ~(4U -1) ))))
71 struct ifinfomsg *ifim = ((void *)0);
72 struct ifaddrmsg *ifam = ((void *)0);
73 struct rtattr *rta;
74 sa_family_t nlm_family = 0;
75 uint32_t nlm_scope = 0, nlm_index = 0;
76 __builtin_memset (&ifamap, 0, sizeof (ifamap));
77 switch (nlh->nlmsg_type)
79 case RTM_NEWLINK:
80 ifim = (struct ifinfomsg *)
81 ((void*)(((char*)nlh)
82 + ((0)+( ((((int)
83 ( ((sizeof(struct nlmsghdr))+4U -1)
84 & ~(4U -1) )))+4U -1)
85 & ~(4U -1) ))));
86 case RTM_NEWADDR:
87 ifam = (struct ifaddrmsg *)
88 ((void*)(((char*)nlh)
89 + ((0)+( ((((int)
90 ( ((sizeof(struct nlmsghdr))+4U -1)
91 & ~(4U -1) )))+4U -1)
92 & ~(4U -1) ))));
93 nlm_family = ifam->ifa_family;
94 if (build)
95 ifa->ifa_flags = ifflist[nlm_index];
96 break;
97 default:
98 continue;
100 if (!build)
102 void *rtadata = ((void*)(((char*)(rta))
103 + (( ((sizeof(struct rtattr))+4 -1)
104 & ~(4 -1) ) + (0))));
105 size_t rtapayload = ((int)((rta)->rta_len)
106 - (( ((sizeof(struct rtattr))+4 -1)
107 & ~(4 -1) ) + (0)));
108 switch (nlh->nlmsg_type)
110 case RTM_NEWLINK:
111 break;
112 case RTM_NEWADDR:
113 if (nlm_family == 17)
114 break;
115 switch (rta->rta_type)
117 case IFA_ADDRESS:
118 ifamap.address = rtadata;
119 ifamap.address_len = rtapayload;
120 case IFA_LOCAL:
121 ifamap.local = rtadata;
125 if (nlh->nlmsg_type == RTM_NEWADDR && nlm_family != 17)
127 if (!ifamap.local)
129 ifamap.local = ifamap.address;
130 ifamap.local_len = ifamap.address_len;
132 if (!ifamap.address)
134 ifamap.address = ifamap.local;
136 if (ifamap.address_len != ifamap.local_len
137 || (ifamap.address != ((void *)0)
138 && __builtin_memcmp (ifamap.address, ifamap.local,
139 ifamap.address_len)))
141 if (!build)
142 dlen += (((ifa_sa_len (nlm_family,
143 ifamap.address_len))+4U -1)
144 & ~(4U -1) );