1 /* { dg-do compile } */
2 /* { dg-additional-options "-Wno-return-type" } */
3 
4 typedef int PRInt32;
5 class nsTreeRows {
6     class Subtree { };
7     enum { kMaxDepth = 32 };
8     struct Link {
9         Subtree* mParent;
10         PRInt32 mChildIndex;
11         Link&         operator=(const Link& aLink) {
12             mParent = aLink.mParent;
13             mChildIndex = aLink.mChildIndex;
14         }
15     };
16     class iterator {
17         PRInt32 mTop;
18         PRInt32 mRowIndex;
19         Link mLink[kMaxDepth];
20     public:
iterator()21         iterator() : mTop(-1), mRowIndex(-1) { }
22         iterator& operator=(const iterator& aIterator);
23     };
24     Subtree*     EnsureSubtreeFor(Subtree* aParent, PRInt32 aChildIndex);
25     Subtree*     GetSubtreeFor(const Subtree* aParent,
26 PRInt32 aChildIndex,                   PRInt32* aSubtreeSize = 0);
InvalidateCachedRow()27     void     InvalidateCachedRow() {
28         mLastRow = iterator();
29     }
30     iterator mLastRow;
31 };
EnsureSubtreeFor(Subtree * aParent,PRInt32 aChildIndex)32 nsTreeRows::Subtree* nsTreeRows::EnsureSubtreeFor(Subtree* aParent,
33                      PRInt32 aChildIndex) {
34     Subtree* subtree = GetSubtreeFor(aParent, aChildIndex);
35     if (! subtree) {
36         InvalidateCachedRow();
37     }
38 }
39 nsTreeRows::iterator& nsTreeRows::iterator::operator=(const iterator&
40 aIterator) {
41     mTop = aIterator.mTop;
42     for (PRInt32 i = mTop;
43          i >= 0;
44          --i)         mLink[i] = aIterator.mLink[i];
45 }
46