1 // { dg-do run }
2 // prms-id: 8155
3
4 int fail = 1;
5
6 class CMainWindow;
7 class CFrameWnd;
8 class CWnd;
9 class CCmdTarget;
10
11 typedef void (CCmdTarget::*AFX_PMSG)( void);
12 typedef void (CWnd::*AFX_PMSGW)( void);
13
14 struct AFX_MSGMAP_ENTRY {
15 unsigned int nMessage;
16 AFX_PMSG pfn;
17 };
18
19 struct AFX_MSGMAP {
20 const AFX_MSGMAP* pBaseMap;
21 const AFX_MSGMAP_ENTRY* lpEntries;
22 };
23
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;
32 };
33
34 const AFX_MSGMAP CCmdTarget::messageMap = {
35 0, &CCmdTarget::_messageEntries[0]
36 };
37
GetMessageMap() const38 const AFX_MSGMAP* CCmdTarget::GetMessageMap() const {
39 return &CCmdTarget::messageMap;
40 }
41
42 AFX_MSGMAP_ENTRY CCmdTarget::_messageEntries[] =
43 {
44 { 0, 0 }
45 };
46
CCmdTarget()47 CCmdTarget :: CCmdTarget() { }
48
49 class CWnd : public CCmdTarget {
50 public:
51 CWnd();
52
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;
60 };
61
CWnd()62 CWnd :: CWnd() {
63 }
64
OnPaint()65 void CWnd :: OnPaint() {
66 }
67
GetMessageMap() const68 const AFX_MSGMAP* CWnd ::GetMessageMap() const {
69 return & CWnd ::messageMap;
70 }
71 const AFX_MSGMAP CWnd ::messageMap = {
72 & CCmdTarget ::messageMap, & CWnd ::_messageEntries[0]
73 };
74 AFX_MSGMAP_ENTRY CWnd ::_messageEntries[] = {
75 {0, (AFX_PMSG)0 } };
76
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;
86 };
87
CFrameWnd()88 CFrameWnd :: CFrameWnd() { }
89
GetMessageMap() const90 const AFX_MSGMAP* CFrameWnd ::GetMessageMap() const {
91 return & CFrameWnd ::messageMap;
92 }
93 const AFX_MSGMAP CFrameWnd ::messageMap = {
94 & CWnd ::messageMap, & CFrameWnd ::_messageEntries[0]
95 };
96 AFX_MSGMAP_ENTRY CFrameWnd ::_messageEntries[] = {
97 {0, (AFX_PMSG)0 } };
98
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;
109 };
110
CMainWindow()111 CMainWindow :: CMainWindow()
112 {
113 }
OnPaint()114 void CMainWindow :: OnPaint()
115 {
116 fail = 0;
117 }
118
callProc()119 void 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
GetMessageMap() const132 const AFX_MSGMAP* CMainWindow ::GetMessageMap() const {
133 return & CMainWindow ::messageMap;
134 }
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 };
142
main(int argc,char ** argv)143 int main( int argc, char **argv) {
144 CMainWindow myWindow;
145
146 myWindow.callProc();
147 return fail;
148 }
149