OSDN Git Service

Merge in xfails from PR14107.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.old-deja / g++.mike / p12306.C
1 // { dg-do run  }
2 // prms-id: 12306
3
4 void *ptr1, *ptr2;
5 int fail = 0;
6
7 extern "C" int printf(const char *...);
8
9 class RWSlist { };
10
11 class RWSlistIterator {
12 public:
13   RWSlist *slist;
14   RWSlistIterator(RWSlist& s) { } 
15   void toLast() {
16     if (ptr1 != (RWSlistIterator*)this)
17       fail = 5;
18     if (ptr2 != &(*this).slist)
19       fail = 6;
20
21     if (0) printf("at %x %x\n", (RWSlistIterator*)this, &(*this).slist);
22   }
23 };
24
25 class RWCollectable {
26 };
27
28 class RWSlistCollectables : public RWSlist {
29 public:  
30   RWSlistCollectables() { }
31   RWSlistCollectables(RWCollectable* a) { }
32 };
33
34 class RWIterator { };     
35
36 class RWSlistCollectablesIterator : public RWIterator, public RWSlistIterator {
37 public:
38   RWSlistCollectablesIterator(RWSlistCollectables& s) : RWSlistIterator(s) { } 
39 };
40
41 class Sim_Event_Manager {
42 public:
43   RWSlistCollectables scheduled_events_;
44   RWSlistCollectablesIterator last_posted_event_position_;
45   Sim_Event_Manager();
46   void post_event();
47 };
48
49 Sim_Event_Manager::Sim_Event_Manager ()
50   :last_posted_event_position_(scheduled_events_)
51 {
52 }
53
54 void Sim_Event_Manager::post_event () {
55   ptr1 = (RWSlistIterator*)&last_posted_event_position_;
56   ptr2 = &((RWSlistIterator*)&last_posted_event_position_)->slist;
57   if (0) printf("at %x %x\n", (RWSlistIterator*)&last_posted_event_position_,
58                 &((RWSlistIterator*)&last_posted_event_position_)->slist);
59   if (ptr1 != (RWSlistIterator*)&last_posted_event_position_)
60     fail = 1;
61   if (ptr2 != &((RWSlistIterator&)last_posted_event_position_).slist)
62     fail = 2;
63   if (0) printf("at %x ?%x\n", (RWSlistIterator*)&last_posted_event_position_,
64                 &((RWSlistIterator&)last_posted_event_position_).slist);
65   if (ptr1 != (RWSlistIterator*)&last_posted_event_position_)
66     fail = 3;
67   if (ptr2 != &((RWSlistIterator&)last_posted_event_position_).slist)
68     fail = 4;
69   last_posted_event_position_.toLast();
70 }
71
72 int main(int argc, char **argv) {
73   Sim_Event_Manager foo;
74   foo.post_event();
75   return fail;
76 }