Dead
[official-gcc.git] / gomp-20050608-branch / gcc / testsuite / g++.old-deja / g++.other / rtti1.C
bloba49695b5c26f936f7497b37fdff8183bab89a581
1 // { dg-do run  }
2 // { dg-options "-frtti" }
3 // test of rtti of non-class types
5 #include <typeinfo>
7 extern "C" {
8   int printf(const char *, ...);
9   void exit(int);
12 int i;
13 short s;
14 char c;
15 long l;
17 unsigned int ui;
18 unsigned short us;
19 unsigned char uc;
20 unsigned long ul;
22 float f;
23 double d;
25 int& ri = i;
26 const volatile int cvi = 10;
27 volatile const int vci = 20;
28 const int ci = 100;
30 int *pi;
31 int ai[10];
33 enum color { red, blue, green, yellow};
35 int (*fp)();
36 int (*gp)();
37 int (*hp)(int);
39 class XX {
40 public:
41   int xxi;
42   float xxf;
43   int xxf1 () { return 0; };
44   int xxf2 (int k) { return 0; };
47 class YY {
48 public:
49   int yyi;
50   double yyd;
51   int yyf1 (float f) { return 0; };
52   double yyf2 () {return yyd;};
55 int XX::*ptmd1;
56 int XX::*ptmd2;
57 float XX::*ptmd3;
58 int YY::*ptmd4;
60 int (XX::*ptmf1) ();
61 int (XX::*ptmf2) ();
62 int (XX::*ptmf3) (int);
63 int (YY::*ptmf4) ();
65 int func1 ()
66 { return 0;}
68 int func2 ()
69 { return 1;}
71 int func3 (int i)
72 { return i;}
74 short func4 ()
75 { return 99;}
77 void error  (int i)
79   exit(i);
82 int main ()
84   if (typeid(i) != typeid(int)) error(1);
85   if (typeid(s) != typeid(short)) error(2);
86   if (typeid(c) != typeid(char)) error(3);
87   if (typeid(l) != typeid(long)) error(4);
88   if (typeid(ui) != typeid(unsigned int)) error(5);
89   if (typeid(us) != typeid(unsigned short)) error(6);
90   if (typeid(uc) != typeid(unsigned char)) error(7);
91   if (typeid(ul) != typeid(unsigned long)) error(8);
92   if (typeid(f) != typeid(float)) error(9);
93   if (typeid(d) != typeid(double)) error(10);
95   if (typeid(*pi) != typeid(int)) error(51);
96   if (typeid(pi) == typeid(ai)) error(52);
97   if (typeid(ri) != typeid(i)) error(53);
98   if (typeid(cvi) != typeid(vci)) error (54);
99   if (typeid(vci) != typeid(i)) error(55);
100   if (typeid(ci) != typeid(cvi)) error (56);
101   if (typeid(ci) != typeid(const int)) error(57);
103   if (typeid(func1) != typeid(func2)) error (81);
104   if (typeid(func2) == typeid(func3)) error (82);
105   if (typeid(func1) == typeid(func4)) error (83);
106   if (typeid(func3) == typeid(func4)) error (84);
108   if (typeid(red) != typeid(color)) error (101);
109   if (typeid(green) != typeid(blue)) error (102);
111   if (typeid(fp) != typeid(gp)) error (103);
112   if (typeid(gp) == typeid(hp)) error (104);
114   if (typeid(ptmd1) != typeid(ptmd2)) error (105);
115   if (typeid(ptmd1) == typeid(ptmd3)) error (106);
116   if (typeid(ptmd2) == typeid(ptmd4)) error (107);
118   if (typeid(ptmf1) != typeid(ptmf2)) error (108);
119   if (typeid(ptmf2) == typeid(ptmf3)) error (109);
120   if (typeid(ptmf1) == typeid(ptmf4)) error (110);
121   return 0;