summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.mike/p2746.C
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.old-deja/g++.mike/p2746.C
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
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.
Diffstat (limited to 'gcc/testsuite/g++.old-deja/g++.mike/p2746.C')
-rw-r--r--gcc/testsuite/g++.old-deja/g++.mike/p2746.C156
1 files changed, 156 insertions, 0 deletions
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 T> class IListIter;
+
+template<class T>
+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<T>;
+};
+
+template<class T>
+IList<T>::~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 T>
+class IListIter : private IListIterBase {
+public:
+ IListIter(const IList<T> &list) : IListIterBase(list) { }
+ T *cur() { return (T *)IListIterBase::cur(); }
+ IListIterBase::next;
+ IListIterBase::done;
+};
+
+
+struct A {
+ IList<Link> list;
+ int x;
+ void foo();
+};
+
+
+void A::foo()
+{
+ for (IListIter<Link> iter(list); !iter.done(); iter.next())
+ ;
+ x = 0;
+}