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