Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/g++.dg/torture/pr42773.C @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children |
line wrap: on
line source
// { dg-do compile } // { dg-options "-fno-exceptions" } typedef unsigned int uint; struct QShared { bool deref() { return !--count; } uint count; }; template <class T> class QValueListNode { public: QValueListNode<T>* next; QValueListNode<T>* prev; }; template <class T> class QValueListPrivate : public QShared { public: typedef QValueListNode<T> Node; typedef QValueListNode<T>* NodePtr; QValueListPrivate(); void derefAndDelete() { if ( deref() ) delete this; } ~QValueListPrivate(); NodePtr node; }; template <class T> QValueListPrivate<T>::QValueListPrivate() { node = new Node; node->next = node->prev = node; } template <class T> QValueListPrivate<T>::~QValueListPrivate() { NodePtr p = node->next; while( p != node ) { NodePtr x = p->next; delete p; p = x; } } template <class T> class QValueList { public: QValueList() { sh = new QValueListPrivate<T>; } ~QValueList() { sh->derefAndDelete(); } QValueListPrivate<T>* sh; }; class Cell { QValueList<Cell*> obscuringCells() const; }; QValueList<Cell*> Cell::obscuringCells() const { QValueList<Cell*> empty; return QValueList<Cell*>(); }