2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.mike / p8155.C
blob79384717cd7556a277a19dd7dcb944e75aaae3a0
1 // { dg-do run  }
2 // prms-id: 8155
4 int fail = 1;
6 class CMainWindow;
7 class CFrameWnd;
8 class CWnd;
9 class CCmdTarget;
11 typedef void (CCmdTarget::*AFX_PMSG)( void);
12 typedef void (CWnd::*AFX_PMSGW)( void);
14 struct AFX_MSGMAP_ENTRY {
15   unsigned int  nMessage;    
16   AFX_PMSG pfn;
19 struct AFX_MSGMAP {
20   const AFX_MSGMAP* pBaseMap;
21   const AFX_MSGMAP_ENTRY* lpEntries;
24 class CCmdTarget {
25 public:
26   CCmdTarget();
27 private:
28   static AFX_MSGMAP_ENTRY _messageEntries[];
29 protected:
30   static const AFX_MSGMAP messageMap;
31   virtual const AFX_MSGMAP* GetMessageMap() const; 
34 const   AFX_MSGMAP CCmdTarget::messageMap = {
35   0, &CCmdTarget::_messageEntries[0]
38 const AFX_MSGMAP* CCmdTarget::GetMessageMap() const {
39   return &CCmdTarget::messageMap;
42 AFX_MSGMAP_ENTRY CCmdTarget::_messageEntries[] =
44   { 0, 0 }
47 CCmdTarget :: CCmdTarget() { }
49 class CWnd : public CCmdTarget {
50 public:
51   CWnd();
53 protected:
54   void OnPaint();
55 private:
56   static AFX_MSGMAP_ENTRY _messageEntries[];
57 protected:
58   static   const AFX_MSGMAP messageMap;
59   virtual const AFX_MSGMAP* GetMessageMap() const; 
62 CWnd :: CWnd() {
65 void CWnd :: OnPaint() {
68 const AFX_MSGMAP*   CWnd ::GetMessageMap() const {
69   return &  CWnd ::messageMap;
71 const AFX_MSGMAP   CWnd ::messageMap = {
72   &  CCmdTarget ::messageMap, &  CWnd ::_messageEntries[0]
73   };
74 AFX_MSGMAP_ENTRY   CWnd ::_messageEntries[] = { 
75   {0, (AFX_PMSG)0 } }; 
77 class CFrameWnd : public CWnd {
78 public:
79   CFrameWnd();
80 protected:
81 private:
82   static AFX_MSGMAP_ENTRY _messageEntries[];
83 protected:
84   static   const AFX_MSGMAP messageMap;
85   virtual const AFX_MSGMAP* GetMessageMap() const; 
88 CFrameWnd :: CFrameWnd() { }
90 const AFX_MSGMAP*   CFrameWnd ::GetMessageMap() const {
91   return &  CFrameWnd ::messageMap;
93 const AFX_MSGMAP   CFrameWnd ::messageMap = {
94   &  CWnd ::messageMap, &  CFrameWnd ::_messageEntries[0]
95   };
96 AFX_MSGMAP_ENTRY   CFrameWnd ::_messageEntries[] = { 
97   {0, (AFX_PMSG)0 } }; 
99 class CMainWindow : public CFrameWnd {
100 public:
101   CMainWindow();
102   void OnPaint();
103   void callProc();
104 private:
105   static AFX_MSGMAP_ENTRY _messageEntries[];
106 protected:
107   static   const AFX_MSGMAP messageMap;
108   virtual const AFX_MSGMAP* GetMessageMap() const; 
111 CMainWindow :: CMainWindow()
114 void CMainWindow :: OnPaint()
116   fail = 0;
119 void CMainWindow :: callProc()
121   const AFX_MSGMAP* pMessageMap;
122   const AFX_MSGMAP_ENTRY *lpEntry;
124   pMessageMap = GetMessageMap();
125   lpEntry = pMessageMap->lpEntries;
127   if( lpEntry->nMessage == 100) {
128     (this->*lpEntry->pfn)();
129   }
132 const AFX_MSGMAP*   CMainWindow ::GetMessageMap() const {
133   return &  CMainWindow ::messageMap;
135 const AFX_MSGMAP   CMainWindow ::messageMap = {
136   &  CFrameWnd ::messageMap, &  CMainWindow ::_messageEntries[0]
137   };
138 AFX_MSGMAP_ENTRY   CMainWindow ::_messageEntries[] = { 
139   { 100, (AFX_PMSG)(AFX_PMSGW)(void (CWnd::*)(void))&CMainWindow::OnPaint },
140   {0, (AFX_PMSG)0 }
141 }; 
143 int main( int argc, char **argv) {
144   CMainWindow     myWindow;
146   myWindow.callProc();
147   return fail;