1 /* { dg-do compile } */
2 extern "C" {
3   typedef __SIZE_TYPE__ size_t;
4   typedef struct   {
5     } __sigset_t;
6   typedef union {
7   } pthread_barrierattr_t;
8   }
9   typedef unsigned short XMLCh;
10       typedef unsigned long XMLSize_t;
11   namespace xercesc_2_5 {
12   class DOMNodeList;
13   class DOMNode {
14   };
15   class DOMDocumentRange {
16   };
17   class DOMDocument: public DOMDocumentRange,  public DOMNode {
18   };
19   union wait   {
20       struct       {
21        }
22   __wait_stopped;
23     }
24  div_t;
25   class MemoryManager;
26   class XMemory {
27   public :     void* operator new(size_t size, MemoryManager* memMgr);
28       void operator delete(void* p);
29       void operator delete(void* p, MemoryManager* memMgr);
30   };
31   class XMLExcepts {
32   public :     enum Codes     {
33          NoError = 0       , HshTbl_ZeroModulus = 48       , HshTbl_BadHashFromKey = 49     };
34   };
35   class XMLUni {
36   };
37   }
38   namespace xercesc_2_5 {
39   class XMLException : public XMemory {
40   public:
41     virtual ~XMLException();
42       XMLException(const char* const srcFile, const unsigned int srcLine, MemoryManager* const memoryManager = 0);
43       void loadExceptText     (         const XMLExcepts::Codes toLoad     );
44   };
45   class XMLDeleter {
46   };
47   class XMLPlatformUtils {
48   public :     static MemoryManager* fgMemoryManager;
49    static inline size_t alignPointerForNewBlockAllocation(size_t ptrSize);
50   };
alignPointerForNewBlockAllocation(size_t ptrSize)51   inline size_t XMLPlatformUtils::alignPointerForNewBlockAllocation(size_t ptrSize) {
52   }
53   class HashBase : public XMemory {
54   public:
55  virtual bool equals(const void *const key1, const void *const key2) = 0;
~HashBase()56       virtual ~HashBase() {
57 };
58   };
59   class IllegalArgumentException : public XMLException {
60   public:
XMLException(srcFile,srcLine,memoryManager)61 IllegalArgumentException(const char* const srcFile , const unsigned int srcLine , const XMLExcepts::Codes toThrow , MemoryManager* memoryManager = 0) : XMLException(srcFile, srcLine, memoryManager) {
62  loadExceptText(toThrow);
63  }
64   };
65   class RuntimeException : public XMLException {
66   public:
XMLException(srcFile,srcLine,memoryManager)67 RuntimeException(const char* const srcFile , const unsigned int srcLine , const XMLExcepts::Codes toThrow , MemoryManager* memoryManager = 0) : XMLException(srcFile, srcLine, memoryManager) {
68  loadExceptText(toThrow);
69  }
70   };
71   class MemoryManager {
72   public:
~MemoryManager()73     virtual ~MemoryManager()     {
74      }
75       virtual void* allocate(size_t size) = 0;
76   };
77   template <class TElem> class BaseRefVectorOf : public XMemory {
78       BaseRefVectorOf     (           const unsigned int maxElems         , const bool adoptElems = true         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager     );
79       virtual ~BaseRefVectorOf();
80       bool fAdoptedElems;
81       TElem** fElemList;
82   };
BaseRefVectorOf(const unsigned int maxElems,const bool adoptElems,MemoryManager * const manager)83   template <class TElem> BaseRefVectorOf<TElem>::BaseRefVectorOf( const unsigned int maxElems                                        , const bool adoptElems                                        , MemoryManager* const manager) :     fAdoptedElems(adoptElems) {
84       for (unsigned int index = 0;
85   index < maxElems;
86   index++)         fElemList[index] = 0;
87   }
~BaseRefVectorOf()88   template <class TElem> BaseRefVectorOf<TElem>::~BaseRefVectorOf() {
89   }
90   class XMLString {
91   public:
92      static bool equals     (           const XMLCh* const str1         , const XMLCh* const str2     );
93       static void moveChars     (                 XMLCh* const targetStr         , const XMLCh* const srcStr         , const unsigned int count     );
94   };
moveChars(XMLCh * const targetStr,const XMLCh * const srcStr,const unsigned int count)95   inline void XMLString::moveChars( XMLCh* const targetStr                                 , const XMLCh* const srcStr                                 , const unsigned int count) {
96   }
equals(const XMLCh * const str1,const XMLCh * const str2)97   inline bool XMLString::equals( const XMLCh* const str1                                , const XMLCh* const str2) {
98       const XMLCh* psz1 = str1;
99       const XMLCh* psz2 = str2;
100       if (psz1 == 0 || psz2 == 0) {
101              return true;
102      }
103   }
104   }
105   namespace xercesc_2_5 {
106   class HashPtr : public HashBase {
107    virtual bool equals(const void *const key1, const void *const key2);
108   };
109   template <class TVal> struct DOMDeepNodeListPoolTableBucketElem : public XMemory {
110       void* fKey1;
111       XMLCh* fKey2;
112       XMLCh* fKey3;
113   };
114   template <class TVal> class DOMDeepNodeListPool {
115   public:
116      DOMDeepNodeListPool     (         const XMLSize_t modulus       , const bool adoptElems       , const XMLSize_t initSize = 128     );
117       TVal* getByKey(const void* const key1, const XMLCh* const key2, const XMLCh* const key3);
118       DOMDeepNodeListPoolTableBucketElem<TVal>* findBucketElem(const void* const key1, const XMLCh* const key2, const XMLCh* const key3, XMLSize_t& hashVal);
119       bool fAdoptedElems;
120       DOMDeepNodeListPoolTableBucketElem<TVal>** fBucketList;
121       XMLSize_t fHashModulus;
122       HashBase* fHash;
123       TVal** fIdPtrs;
124       XMLSize_t fIdPtrsCount;
125       MemoryManager* fMemoryManager;
126   };
DOMDeepNodeListPool(const XMLSize_t modulus,const bool adoptElems,const XMLSize_t initSize)127   template <class TVal> DOMDeepNodeListPool<TVal>::DOMDeepNodeListPool( const XMLSize_t modulus                                               , const bool adoptElems                                               , const XMLSize_t initSize) :   fAdoptedElems(adoptElems)     , fBucketList(0)     , fHash(0)     , fIdPtrs(0) {
128       fHash = new (fMemoryManager) HashPtr();
129       fIdPtrs = (TVal**) fMemoryManager->allocate(fIdPtrsCount * sizeof(TVal*));
130    if (modulus == 0)         throw IllegalArgumentException("./xercesc/dom/impl/bad.c", 38, XMLExcepts::HshTbl_ZeroModulus, fMemoryManager);
131   }
getByKey(const void * const key1,const XMLCh * const key2,const XMLCh * const key3)132   template <class TVal> TVal* DOMDeepNodeListPool<TVal>::getByKey(const void* const key1, const XMLCh* const key2, const XMLCh* const key3) {
133       XMLSize_t hashVal;
134       DOMDeepNodeListPoolTableBucketElem<TVal>* findIt = findBucketElem(key1, key2, key3, hashVal);
135   }
findBucketElem(const void * const key1,const XMLCh * const key2,const XMLCh * const key3,XMLSize_t & hashVal)136   template <class TVal> DOMDeepNodeListPoolTableBucketElem<TVal>* DOMDeepNodeListPool<TVal>:: findBucketElem(const void* const key1, const XMLCh* const key2, const XMLCh* const key3, XMLSize_t& hashVal) {
137       if (hashVal > fHashModulus)         throw RuntimeException("./xercesc/dom/impl/bad.c", 64, XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager);
138       DOMDeepNodeListPoolTableBucketElem<TVal>* curElem = fBucketList[hashVal];
139           if (fHash->equals(key1, curElem->fKey1) && (XMLString::equals(key2, curElem->fKey2)) && (XMLString::equals(key3, curElem->fKey3))) {
140              return curElem;
141      }
142   }
143   class DOMDeepNodeListImpl;
144   class DOMDocumentImpl: public DOMDocument {
145       DOMNodeList* getElementsByTagName(const XMLCh * tagname) const;
146       DOMNodeList* getDeepNodeList(const DOMNode *rootNode, const XMLCh *tagName);
147       DOMNodeList* getDeepNodeList(const DOMNode *rootNode,                                                  const XMLCh *namespaceURI,                                                  const XMLCh *localName);
148       DOMDeepNodeListPool<DOMDeepNodeListImpl>* fNodeListPool;
149   };
150   }
151   void * operator new(size_t amt, xercesc_2_5:: DOMDocument *doc);
152   namespace xercesc_2_5 {
153   class DOMNodeList {
154   };
155   class DOMDeepNodeListImpl: public DOMNodeList {
156   };
getElementsByTagName(const XMLCh * tagname)157   DOMNodeList *DOMDocumentImpl::getElementsByTagName(const XMLCh *tagname) const {
158       return ((DOMDocumentImpl*)this)->getDeepNodeList(this,tagname);
159   }
getDeepNodeList(const DOMNode * rootNode,const XMLCh * tagName)160   DOMNodeList *DOMDocumentImpl::getDeepNodeList(const DOMNode *rootNode, const XMLCh *tagName) {
161       if(!fNodeListPool) {
162          fNodeListPool = new (this) DOMDeepNodeListPool<DOMDeepNodeListImpl>(109, false);
163      }
164       DOMNodeList* retList = fNodeListPool->getByKey(rootNode, tagName, 0);
165   }
getDeepNodeList(const DOMNode * rootNode,const XMLCh * namespaceURI,const XMLCh * localName)166   DOMNodeList *DOMDocumentImpl::getDeepNodeList(const DOMNode *rootNode,                                                    const XMLCh *namespaceURI,                                                    const XMLCh *localName) {
167       DOMNodeList* retList = fNodeListPool->getByKey(rootNode, localName, namespaceURI);
168   }
169   }
170 
171