From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/g++.old-deja/g++.mike/p2746.C | 156 ++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 gcc/testsuite/g++.old-deja/g++.mike/p2746.C (limited to 'gcc/testsuite/g++.old-deja/g++.mike/p2746.C') diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p2746.C b/gcc/testsuite/g++.old-deja/g++.mike/p2746.C new file mode 100644 index 000000000..1bc1ce359 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p2746.C @@ -0,0 +1,156 @@ +// { dg-do assemble } +// GROUPS passed scope pt +class Link { +public: + Link(); + Link(Link *); +private: + Link *next_; + +friend class IListBase; +friend class IListIterBase; +}; + +inline +Link::Link() : next_(0) +{ +} + +inline +Link::Link(Link *next) : next_(next) +{ +} + +class IListBase { +public: + IListBase(); + IListBase(Link *); + void append(Link *); + void insert(Link *); + Link *head(); + int empty(); + Link *get(); + void remove(Link *); +private: + Link *head_; +friend class IListIterBase; +}; + +inline +IListBase::IListBase() : head_(0) +{ +} + +inline +IListBase::IListBase(Link *head) : head_(head) +{ +} + +inline +void IListBase::insert(Link *p) +{ + p->next_ = head_; + head_ = p; +} + +inline +Link *IListBase::head() +{ + return head_; +} + +inline +int IListBase::empty() +{ + return head_ == 0; +} + +inline +Link *IListBase::get() +{ + Link *tem = head_; + head_ = head_->next_; + return tem; +} + +template class IListIter; + +template +class IList : private IListBase { +public: + IList() { } + IList(T *p) : IListBase(p) { } + ~IList(); + void append(T *p) { IListBase::append(p); } + void insert(T *p) { IListBase::insert(p); } + void remove(T *p) { IListBase::remove(p); } + T *head() { return (T *)IListBase::head(); } + T *get() { return (T *)IListBase::get(); } + IListBase::empty; +friend class IListIter; +}; + +template +IList::~IList() +{ + while (!empty()) + delete get(); +} + +class IListIterBase { +public: + IListIterBase(const IListBase &); + int done(); + Link *cur(); + void next(); +private: + Link *p_; +}; + +inline +IListIterBase::IListIterBase(const IListBase &list) : p_(list.head_) +{ +} + +inline +int IListIterBase::done() +{ + return p_ == 0; +} + +inline +Link *IListIterBase::cur() +{ + return p_; +} + +inline +void IListIterBase::next() +{ + p_ = p_->next_; +} + + +template +class IListIter : private IListIterBase { +public: + IListIter(const IList &list) : IListIterBase(list) { } + T *cur() { return (T *)IListIterBase::cur(); } + IListIterBase::next; + IListIterBase::done; +}; + + +struct A { + IList list; + int x; + void foo(); +}; + + +void A::foo() +{ + for (IListIter iter(list); !iter.done(); iter.next()) + ; + x = 0; +} -- cgit v1.2.3