aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/20020430-1.c
blob: 8fcdfba0f33339480dcc2ced99332b3748d5ada7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/* PR opt/6516 */
/* On x86, something about the structure of this function prevented
   cross-jumping from combining the three arms of the switch statement
   until the last moment.  After which we did not delete dead code, 
   which left a reference to the deleted ADDR_VEC.  */

/* { dg-do compile { target fpic } } */
/* { dg-options "-O2 -frename-registers -fpic" } */

typedef unsigned long XID;
typedef XID Window;
typedef void Display;
typedef unsigned long Time;

typedef struct {
        int type;
        unsigned long serial;
        int send_event;
        Display *display;
        Window window;
        Window root;
        Window subwindow;
        Time time;
        int x, y;
        int x_root, y_root;
        unsigned int state;
        unsigned int button;
        int same_screen;
} XButtonEvent;
typedef struct {
        int type;
        unsigned long serial;
        int send_event;
        Display *display;
        Window window;
        Window root;
        Window subwindow;
        Time time;
        int x, y;
        int x_root, y_root;
        unsigned int state;
        char is_hint;
        int same_screen;
} XMotionEvent;
typedef struct {
        int type;
        unsigned long serial;
        int send_event;
        Display *display;
        Window window;
        Window root;
        Window subwindow;
        Time time;
        int x, y;
        int x_root, y_root;
        int mode;
        int detail;
        int same_screen;
        int focus;
        unsigned int state;
} XCrossingEvent;
typedef union _XEvent {
        int type;
        XButtonEvent xbutton;
        XMotionEvent xmotion;
        XCrossingEvent xcrossing;
} XEvent;

typedef struct {
        int width, height;
        Display *display;
} Screen;
typedef struct _CorePart {
    Screen *screen;
} CorePart;
typedef struct _WidgetRec {
    CorePart core;
} WidgetRec;
typedef struct _WidgetRec *Widget;

typedef struct _SmeRec *SmeObject;
typedef struct _SimpleMenuPart {
    SmeObject entry_set;
} SimpleMenuPart;
typedef struct _SimpleMenuRec {
    SimpleMenuPart simple_menu;
} SimpleMenuRec;
typedef struct _SimpleMenuRec* SimpleMenuWidget;

typedef short Position;
typedef unsigned short Dimension;
typedef char Boolean;

typedef struct _RectObjPart {
    Position x, y;
    Dimension width, height;
    Dimension border_width;
    Boolean managed;
    Boolean sensitive;
    Boolean ancestor_sensitive;
}RectObjPart;
typedef struct _RectObjRec {
    RectObjPart rectangle;
} RectObjRec;
typedef struct _RectObjRec *RectObj;

SmeObject DoGetEventEntry();

SmeObject
GetEventEntry(Widget w, XEvent *event)
{
    int x_loc, y_loc, x_root;
    SimpleMenuWidget smw = (SimpleMenuWidget)w;
    SmeObject entry;
    int warp, move;
    switch (event->type) {
        case 6:
            x_loc = event->xmotion.x;
            y_loc = event->xmotion.y;
            x_root = event->xmotion.x_root;
            break;
        case 7:
        case 8:
            x_loc = event->xcrossing.x;
            y_loc = event->xcrossing.y;
            x_root = event->xcrossing.x_root;
            break;
        case 4:
        case 5:
            x_loc = event->xbutton.x;
            y_loc = event->xbutton.y;
            x_root = event->xbutton.x_root;
            break;
        default:
            XtAppError(XtWidgetToApplicationContext(w),
                       "Unknown event type in GetEventEntry().");
            return (((void *)0));
    }
    if (x_loc < 0 || x_loc >= (((RectObj)smw)->rectangle.width) ||
        y_loc < 0 || y_loc >= (((RectObj)smw)->rectangle.height))
        return (((void *)0));
    if (x_root == ((((w)->core.screen))->width) - 1 &&
        (((RectObj)w)->rectangle.x) + (((RectObj)w)->rectangle.width) + ((((RectObj)w)->rectangle.border_width)) > x_root) {
        warp = -8;
        if (smw->simple_menu.entry_set) {
            entry = DoGetEventEntry(w,
                                    (((RectObj)smw->simple_menu.entry_set)->rectangle.x)
                                    + (((RectObj)smw->simple_menu.entry_set)->rectangle.width) + 1,
                                    y_loc);
            Unhighlight(w, event, ((void *)0), ((void *)0));
            if (entry) {
                warp = -(int)(((RectObj)entry)->rectangle.width) >> 1;
                move = x_loc - (((RectObj)entry)->rectangle.width) - (((RectObj)entry)->rectangle.x) + (((RectObj)w)->rectangle.border_width);
            }
            else {
                warp = 0;
                move = ((((w)->core.screen))->width) -
                       ((((RectObj)w)->rectangle.x) + (((RectObj)w)->rectangle.width) + ((((RectObj)w)->rectangle.border_width) << 1));
            }
        }
        else {
            warp = 0;
            move = ((((w)->core.screen))->width) -
                   ((((RectObj)w)->rectangle.x) + (((RectObj)w)->rectangle.width) + ((((RectObj)w)->rectangle.border_width) << 1));
        }
    }
    else if (x_root == 0 && (((RectObj)w)->rectangle.x) < 0) {
        warp = 8;
        if (smw->simple_menu.entry_set) {
            entry = DoGetEventEntry(w, (((RectObj)smw->simple_menu.entry_set)->rectangle.x) - 1,
                                    y_loc);
            Unhighlight(w, event, ((void *)0), ((void *)0));
            if (entry) {
                warp = (((RectObj)entry)->rectangle.width) >> 1;
                move = x_loc - (((RectObj)entry)->rectangle.x);
            }
            else
                move = x_loc + (((RectObj)w)->rectangle.border_width);
        }
        else
            move = x_loc + (((RectObj)w)->rectangle.border_width);
    }
    else
        move = warp = 0;
    if (move)
        XtMoveWidget(w, (((RectObj)w)->rectangle.x) + move, (((RectObj)w)->rectangle.y));
    if (warp)
        XWarpPointer((((w)->core.screen)->display), 0L, 0L, 0, 0, 0, 0, warp, 0);
    return (DoGetEventEntry(w, x_loc, y_loc));
}