1// { dg-do run  }
2// prms-id: 8155
3
4int fail = 1;
5
6class CMainWindow;
7class CFrameWnd;
8class CWnd;
9class CCmdTarget;
10
11typedef void (CCmdTarget::*AFX_PMSG)( void);
12typedef void (CWnd::*AFX_PMSGW)( void);
13
14struct AFX_MSGMAP_ENTRY {
15  unsigned int  nMessage;
16  AFX_PMSG pfn;
17};
18
19struct AFX_MSGMAP {
20  const AFX_MSGMAP* pBaseMap;
21  const AFX_MSGMAP_ENTRY* lpEntries;
22};
23
24class CCmdTarget {
25public:
26  CCmdTarget();
27private:
28  static AFX_MSGMAP_ENTRY _messageEntries[];
29protected:
30  static const AFX_MSGMAP messageMap;
31  virtual const AFX_MSGMAP* GetMessageMap() const;
32};
33
34const   AFX_MSGMAP CCmdTarget::messageMap = {
35  0, &CCmdTarget::_messageEntries[0]
36};
37
38const AFX_MSGMAP* CCmdTarget::GetMessageMap() const {
39  return &CCmdTarget::messageMap;
40}
41
42AFX_MSGMAP_ENTRY CCmdTarget::_messageEntries[] =
43{
44  { 0, 0 }
45};
46
47CCmdTarget :: CCmdTarget() { }
48
49class CWnd : public CCmdTarget {
50public:
51  CWnd();
52
53protected:
54  void OnPaint();
55private:
56  static AFX_MSGMAP_ENTRY _messageEntries[];
57protected:
58  static   const AFX_MSGMAP messageMap;
59  virtual const AFX_MSGMAP* GetMessageMap() const;
60};
61
62CWnd :: CWnd() {
63}
64
65void CWnd :: OnPaint() {
66}
67
68const AFX_MSGMAP*   CWnd ::GetMessageMap() const {
69  return &  CWnd ::messageMap;
70}
71const AFX_MSGMAP   CWnd ::messageMap = {
72  &  CCmdTarget ::messageMap, &  CWnd ::_messageEntries[0]
73  };
74AFX_MSGMAP_ENTRY   CWnd ::_messageEntries[] = {
75  {0, (AFX_PMSG)0 } };
76
77class CFrameWnd : public CWnd {
78public:
79  CFrameWnd();
80protected:
81private:
82  static AFX_MSGMAP_ENTRY _messageEntries[];
83protected:
84  static   const AFX_MSGMAP messageMap;
85  virtual const AFX_MSGMAP* GetMessageMap() const;
86};
87
88CFrameWnd :: CFrameWnd() { }
89
90const AFX_MSGMAP*   CFrameWnd ::GetMessageMap() const {
91  return &  CFrameWnd ::messageMap;
92}
93const AFX_MSGMAP   CFrameWnd ::messageMap = {
94  &  CWnd ::messageMap, &  CFrameWnd ::_messageEntries[0]
95  };
96AFX_MSGMAP_ENTRY   CFrameWnd ::_messageEntries[] = {
97  {0, (AFX_PMSG)0 } };
98
99class CMainWindow : public CFrameWnd {
100public:
101  CMainWindow();
102  void OnPaint();
103  void callProc();
104private:
105  static AFX_MSGMAP_ENTRY _messageEntries[];
106protected:
107  static   const AFX_MSGMAP messageMap;
108  virtual const AFX_MSGMAP* GetMessageMap() const;
109};
110
111CMainWindow :: CMainWindow()
112{
113}
114void CMainWindow :: OnPaint()
115{
116  fail = 0;
117}
118
119void CMainWindow :: callProc()
120{
121  const AFX_MSGMAP* pMessageMap;
122  const AFX_MSGMAP_ENTRY *lpEntry;
123
124  pMessageMap = GetMessageMap();
125  lpEntry = pMessageMap->lpEntries;
126
127  if( lpEntry->nMessage == 100) {
128    (this->*lpEntry->pfn)();
129  }
130}
131
132const AFX_MSGMAP*   CMainWindow ::GetMessageMap() const {
133  return &  CMainWindow ::messageMap;
134}
135const AFX_MSGMAP   CMainWindow ::messageMap = {
136  &  CFrameWnd ::messageMap, &  CMainWindow ::_messageEntries[0]
137  };
138AFX_MSGMAP_ENTRY   CMainWindow ::_messageEntries[] = {
139  { 100, (AFX_PMSG)(AFX_PMSGW)(void (CWnd::*)(void))&CMainWindow::OnPaint },
140  {0, (AFX_PMSG)0 }
141};
142
143int main( int argc, char **argv) {
144  CMainWindow     myWindow;
145
146  myWindow.callProc();
147  return fail;
148}
149