2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.mike / p12306.C
blob6309016a308d336044ab6ac0afd2c56abdd22f7a
1 // { dg-do run  }
2 // prms-id: 12306
4 void *ptr1, *ptr2;
5 int fail = 0;
7 extern "C" int printf(const char *...);
9 class RWSlist { };
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;
21     if (0) printf("at %x %x\n", (RWSlistIterator*)this, &(*this).slist);
22   }
25 class RWCollectable {
28 class RWSlistCollectables : public RWSlist {
29 public:  
30   RWSlistCollectables() { }
31   RWSlistCollectables(RWCollectable* a) { }
34 class RWIterator { };     
36 class RWSlistCollectablesIterator : public RWIterator, public RWSlistIterator {
37 public:
38   RWSlistCollectablesIterator(RWSlistCollectables& s) : RWSlistIterator(s) { } 
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();
49 Sim_Event_Manager::Sim_Event_Manager ()
50   :last_posted_event_position_(scheduled_events_)
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();
72 int main(int argc, char **argv) {
73   Sim_Event_Manager foo;
74   foo.post_event();
75   return fail;