2018-05-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / pr59350.c
blob3d38486760f1dade4b3516fad03ad492624ad62a
1 /* PR debug/59350 */
2 /* Testcase by Ryan Mansfield <rmansfield@qnx.com> */
4 /* { dg-do compile } */
5 /* { dg-options "-O -g" } */
7 typedef union
9 char b[2];
10 short NotAnInteger;
12 mDNSOpaque16;
13 typedef mDNSOpaque16 mDNSIPPort;
14 typedef struct
17 mDNSAddr;
18 typedef struct DNSQuestion_struct DNSQuestion;
19 typedef struct mDNS_struct mDNS;
20 typedef struct __attribute__ ((__packed__))
22 mDNSOpaque16 id;
23 mDNSOpaque16 flags;
26 DNSMessageHeader;
27 typedef struct __attribute__ ((__packed__))
29 DNSMessageHeader h;
32 DNSMessage;
33 struct DNSQuestion_struct
35 DNSQuestion *next;
36 long LastQTime;
37 mDNSOpaque16 TargetQID;
39 struct mDNS_struct
41 long timenow;
42 DNSQuestion *Questions;
44 extern long mDNSPlatformOneSecond;
45 typedef enum
47 kDNSFlag0_QR_Mask = 0x80, kDNSFlag0_QR_Query = 0x00, kDNSFlag0_QR_Response =
48 0x80, kDNSFlag0_OP_Mask = 0x78, kDNSFlag0_OP_StdQuery =
49 0x00, kDNSFlag0_OP_Iquery = 0x08, kDNSFlag0_OP_Status =
50 0x10, kDNSFlag0_OP_Unused3 = 0x18, kDNSFlag0_OP_Notify =
51 0x20, kDNSFlag0_OP_Update = 0x28, kDNSFlag0_QROP_Mask =
52 kDNSFlag0_QR_Mask | kDNSFlag0_OP_Mask, kDNSFlag0_AA = 0x04, kDNSFlag0_TC =
53 0x02, kDNSFlag0_RD = 0x01, kDNSFlag1_RA = 0x80, kDNSFlag1_Zero =
54 0x40, kDNSFlag1_AD = 0x20, kDNSFlag1_CD = 0x10, kDNSFlag1_RC_Mask =
55 0x0F, kDNSFlag1_RC_NoErr = 0x00, kDNSFlag1_RC_FormErr =
56 0x01, kDNSFlag1_RC_ServFail = 0x02, kDNSFlag1_RC_NXDomain =
57 0x03, kDNSFlag1_RC_NotImpl = 0x04, kDNSFlag1_RC_Refused =
58 0x05, kDNSFlag1_RC_YXDomain = 0x06, kDNSFlag1_RC_YXRRSet =
59 0x07, kDNSFlag1_RC_NXRRSet = 0x08, kDNSFlag1_RC_NotAuth =
60 0x09, kDNSFlag1_RC_NotZone = 0x0A
62 TSIG_ErrorCode;
63 int uDNS_ReceiveTestQuestionResponse (mDNS * const, DNSMessage * const,
64 const char * const,
65 const mDNSAddr * const,
66 const mDNSIPPort);
67 void
68 uDNS_ReceiveMsg (mDNS * const m, DNSMessage * const msg,
69 const char * const end, const mDNSAddr * const srcaddr,
70 const mDNSIPPort srcport)
72 DNSQuestion *qptr;
73 char StdR = kDNSFlag0_QR_Response | kDNSFlag0_OP_StdQuery;
74 char QR_OP = (char) (msg->h.flags.b[0] & kDNSFlag0_QROP_Mask);
75 if (QR_OP == StdR)
77 if (uDNS_ReceiveTestQuestionResponse (m, msg, end, srcaddr, srcport))
78 return;
79 for (qptr = m->Questions; qptr; qptr = qptr->next)
80 if (msg->h.flags.b[0] & kDNSFlag0_TC
81 && ((qptr->TargetQID).NotAnInteger == (msg->h.id).NotAnInteger)
82 && m->timenow - qptr->LastQTime < (60 * mDNSPlatformOneSecond))