HSA: support alignment for hsa_symbols (PR hsa/70391)
[official-gcc.git] / libvtv / testsuite / libvtv.cc / xlan-test.cc
blob213ed613fbb440aa5833d13330c1082ffa591525
1 // { dg-do run }
3 #include <stdio.h>
4 #include <stdlib.h>
6 class XMemory
8 public:
9 void * operator new (size_t size);
10 void operator delete (void *p);
12 protected:
13 XMemory () {}
15 virtual ~XMemory() {}
18 class XSerializable
20 public:
21 virtual ~XSerializable () {};
23 virtual bool isSerializable() const = 0;
24 virtual void serialize () = 0;
26 protected:
27 XSerializable() {};
31 class Grammar: public XSerializable, public XMemory
33 public:
34 enum GrammarType {
35 DTDGrammarType,
36 SchemaGrammarType,
37 OtherGrammarType,
38 Unknown
41 virtual ~Grammar() {}
43 virtual GrammarType getGrammarType() const = 0;
44 virtual bool getValidated() const = 0;
46 virtual bool isSerializable() const;
47 virtual void serialize ();
49 protected:
50 Grammar() {};
54 class SchemaGrammar : public Grammar
56 public:
58 SchemaGrammar () : Grammar(), elemID(10) { fValidated = true; }
60 virtual ~SchemaGrammar() {}
62 virtual Grammar::GrammarType getGrammarType() const;
63 virtual bool getValidated() const;
65 virtual bool isSerializable () const;
66 virtual void serialize ();
68 private:
69 const unsigned int elemID;
70 bool fValidated;
74 class OtherGrammar : public Grammar
76 public:
78 OtherGrammar () : Grammar(), elemID(10) { fValidated = true; }
80 virtual ~OtherGrammar() {}
82 virtual Grammar::GrammarType getGrammarType() const;
83 virtual bool getValidated() const;
85 virtual bool isSerializable () const;
86 virtual void serialize ();
88 private:
89 const unsigned int elemID;
90 bool fValidated;
94 void
95 Grammar::serialize ()
97 printf ("in Grammar::serialize\n");
100 bool
101 Grammar::isSerializable () const
103 return true;
106 bool
107 SchemaGrammar::isSerializable () const
109 return true;
112 void
113 SchemaGrammar::serialize ()
115 printf ("in SchemaGrammar::serialize\n");
118 Grammar::GrammarType
119 SchemaGrammar::getGrammarType() const {
120 return Grammar::SchemaGrammarType;
123 bool
124 SchemaGrammar::getValidated () const
126 return fValidated;
129 void *
130 XMemory::operator new (size_t size)
132 return malloc (size);
135 void
136 XMemory::operator delete (void *p)
140 bool
141 OtherGrammar::isSerializable () const
143 return false;
146 void
147 OtherGrammar::serialize ()
149 printf ("in OtherGrammar::serialize\n");
152 Grammar::GrammarType
153 OtherGrammar::getGrammarType() const {
154 return Grammar::OtherGrammarType;
157 bool
158 OtherGrammar::getValidated () const
160 return fValidated;
164 main (int argc, char **argv)
166 SchemaGrammar sPtr;
167 OtherGrammar oPtr;
168 Grammar &sGrammar = sPtr;
170 for (int i = 0; i < 2; ++i)
172 if (i == 0)
173 sGrammar = oPtr;
174 else
175 sGrammar = sPtr;
177 if (sGrammar.getGrammarType() != Grammar::SchemaGrammarType ||
178 sGrammar.getValidated ())
179 printf ("if condition was true.\n");
180 else
181 printf ("if condition was false.\n");
184 return 0;