1 /* PR opt/6516 */
2 /* On x86, something about the structure of this function prevented
3    cross-jumping from combining the three arms of the switch statement
4    until the last moment.  After which we did not delete dead code,
5    which left a reference to the deleted ADDR_VEC.  */
6 
7 /* { dg-do compile { target fpic } } */
8 /* { dg-options "-O2 -frename-registers -fpic" } */
9 
10 typedef unsigned long XID;
11 typedef XID Window;
12 typedef void Display;
13 typedef unsigned long Time;
14 
15 typedef struct {
16         int type;
17         unsigned long serial;
18         int send_event;
19         Display *display;
20         Window window;
21         Window root;
22         Window subwindow;
23         Time time;
24         int x, y;
25         int x_root, y_root;
26         unsigned int state;
27         unsigned int button;
28         int same_screen;
29 } XButtonEvent;
30 typedef struct {
31         int type;
32         unsigned long serial;
33         int send_event;
34         Display *display;
35         Window window;
36         Window root;
37         Window subwindow;
38         Time time;
39         int x, y;
40         int x_root, y_root;
41         unsigned int state;
42         char is_hint;
43         int same_screen;
44 } XMotionEvent;
45 typedef struct {
46         int type;
47         unsigned long serial;
48         int send_event;
49         Display *display;
50         Window window;
51         Window root;
52         Window subwindow;
53         Time time;
54         int x, y;
55         int x_root, y_root;
56         int mode;
57         int detail;
58         int same_screen;
59         int focus;
60         unsigned int state;
61 } XCrossingEvent;
62 typedef union _XEvent {
63         int type;
64         XButtonEvent xbutton;
65         XMotionEvent xmotion;
66         XCrossingEvent xcrossing;
67 } XEvent;
68 
69 typedef struct {
70         int width, height;
71         Display *display;
72 } Screen;
73 typedef struct _CorePart {
74     Screen *screen;
75 } CorePart;
76 typedef struct _WidgetRec {
77     CorePart core;
78 } WidgetRec;
79 typedef struct _WidgetRec *Widget;
80 
81 typedef struct _SmeRec *SmeObject;
82 typedef struct _SimpleMenuPart {
83     SmeObject entry_set;
84 } SimpleMenuPart;
85 typedef struct _SimpleMenuRec {
86     SimpleMenuPart simple_menu;
87 } SimpleMenuRec;
88 typedef struct _SimpleMenuRec* SimpleMenuWidget;
89 
90 typedef short Position;
91 typedef unsigned short Dimension;
92 typedef char Boolean;
93 
94 typedef struct _RectObjPart {
95     Position x, y;
96     Dimension width, height;
97     Dimension border_width;
98     Boolean managed;
99     Boolean sensitive;
100     Boolean ancestor_sensitive;
101 }RectObjPart;
102 typedef struct _RectObjRec {
103     RectObjPart rectangle;
104 } RectObjRec;
105 typedef struct _RectObjRec *RectObj;
106 
107 SmeObject DoGetEventEntry();
108 int XtWidgetToApplicationContext();
109 void XtAppError();
110 void Unhighlight();
111 void XtMoveWidget();
112 void XWarpPointer();
113 
114 SmeObject
GetEventEntry(Widget w,XEvent * event)115 GetEventEntry(Widget w, XEvent *event)
116 {
117     int x_loc, y_loc, x_root;
118     SimpleMenuWidget smw = (SimpleMenuWidget)w;
119     SmeObject entry;
120     int warp, move;
121     switch (event->type) {
122         case 6:
123             x_loc = event->xmotion.x;
124             y_loc = event->xmotion.y;
125             x_root = event->xmotion.x_root;
126             break;
127         case 7:
128         case 8:
129             x_loc = event->xcrossing.x;
130             y_loc = event->xcrossing.y;
131             x_root = event->xcrossing.x_root;
132             break;
133         case 4:
134         case 5:
135             x_loc = event->xbutton.x;
136             y_loc = event->xbutton.y;
137             x_root = event->xbutton.x_root;
138             break;
139         default:
140             XtAppError(XtWidgetToApplicationContext(w),
141                        "Unknown event type in GetEventEntry().");
142             return (((void *)0));
143     }
144     if (x_loc < 0 || x_loc >= (((RectObj)smw)->rectangle.width) ||
145         y_loc < 0 || y_loc >= (((RectObj)smw)->rectangle.height))
146         return (((void *)0));
147     if (x_root == ((((w)->core.screen))->width) - 1 &&
148         (((RectObj)w)->rectangle.x) + (((RectObj)w)->rectangle.width) + ((((RectObj)w)->rectangle.border_width)) > x_root) {
149         warp = -8;
150         if (smw->simple_menu.entry_set) {
151             entry = DoGetEventEntry(w,
152                                     (((RectObj)smw->simple_menu.entry_set)->rectangle.x)
153                                     + (((RectObj)smw->simple_menu.entry_set)->rectangle.width) + 1,
154                                     y_loc);
155             Unhighlight(w, event, ((void *)0), ((void *)0));
156             if (entry) {
157                 warp = -(int)(((RectObj)entry)->rectangle.width) >> 1;
158                 move = x_loc - (((RectObj)entry)->rectangle.width) - (((RectObj)entry)->rectangle.x) + (((RectObj)w)->rectangle.border_width);
159             }
160             else {
161                 warp = 0;
162                 move = ((((w)->core.screen))->width) -
163                        ((((RectObj)w)->rectangle.x) + (((RectObj)w)->rectangle.width) + ((((RectObj)w)->rectangle.border_width) << 1));
164             }
165         }
166         else {
167             warp = 0;
168             move = ((((w)->core.screen))->width) -
169                    ((((RectObj)w)->rectangle.x) + (((RectObj)w)->rectangle.width) + ((((RectObj)w)->rectangle.border_width) << 1));
170         }
171     }
172     else if (x_root == 0 && (((RectObj)w)->rectangle.x) < 0) {
173         warp = 8;
174         if (smw->simple_menu.entry_set) {
175             entry = DoGetEventEntry(w, (((RectObj)smw->simple_menu.entry_set)->rectangle.x) - 1,
176                                     y_loc);
177             Unhighlight(w, event, ((void *)0), ((void *)0));
178             if (entry) {
179                 warp = (((RectObj)entry)->rectangle.width) >> 1;
180                 move = x_loc - (((RectObj)entry)->rectangle.x);
181             }
182             else
183                 move = x_loc + (((RectObj)w)->rectangle.border_width);
184         }
185         else
186             move = x_loc + (((RectObj)w)->rectangle.border_width);
187     }
188     else
189         move = warp = 0;
190     if (move)
191         XtMoveWidget(w, (((RectObj)w)->rectangle.x) + move, (((RectObj)w)->rectangle.y));
192     if (warp)
193         XWarpPointer((((w)->core.screen)->display), 0L, 0L, 0, 0, 0, 0, warp, 0);
194     return (DoGetEventEntry(w, x_loc, y_loc));
195 }
196