1 // { dg-do run  }
2 // { dg-options "-frtti" }
3 // test of rtti of non-class types
4 
5 #include <typeinfo>
6 
7 extern "C" {
8   int printf(const char *, ...);
9   void exit(int);
10 }
11 
12 int i;
13 short s;
14 char c;
15 long l;
16 
17 unsigned int ui;
18 unsigned short us;
19 unsigned char uc;
20 unsigned long ul;
21 
22 float f;
23 double d;
24 
25 int& ri = i;
26 const volatile int cvi = 10;
27 volatile const int vci = 20;
28 const int ci = 100;
29 
30 int *pi;
31 int ai[10];
32 
33 enum color { red, blue, green, yellow};
34 
35 int (*fp)();
36 int (*gp)();
37 int (*hp)(int);
38 
39 class XX {
40 public:
41   int xxi;
42   float xxf;
xxf1()43   int xxf1 () { return 0; };
xxf2(int k)44   int xxf2 (int k) { return 0; };
45 };
46 
47 class YY {
48 public:
49   int yyi;
50   double yyd;
yyf1(float f)51   int yyf1 (float f) { return 0; };
yyf2()52   double yyf2 () {return yyd;};
53 };
54 
55 int XX::*ptmd1;
56 int XX::*ptmd2;
57 float XX::*ptmd3;
58 int YY::*ptmd4;
59 
60 int (XX::*ptmf1) ();
61 int (XX::*ptmf2) ();
62 int (XX::*ptmf3) (int);
63 int (YY::*ptmf4) ();
64 
func1()65 int func1 ()
66 { return 0;}
67 
func2()68 int func2 ()
69 { return 1;}
70 
func3(int i)71 int func3 (int i)
72 { return i;}
73 
func4()74 short func4 ()
75 { return 99;}
76 
error(int i)77 void error  (int i)
78 {
79   exit(i);
80 }
81 
main()82 int main ()
83 {
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);
94 
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);
102 
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);
107 
108   if (typeid(red) != typeid(color)) error (101);
109   if (typeid(green) != typeid(blue)) error (102);
110 
111   if (typeid(fp) != typeid(gp)) error (103);
112   if (typeid(gp) == typeid(hp)) error (104);
113 
114   if (typeid(ptmd1) != typeid(ptmd2)) error (105);
115   if (typeid(ptmd1) == typeid(ptmd3)) error (106);
116   if (typeid(ptmd2) == typeid(ptmd4)) error (107);
117 
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;
122 }
123