Debian Codegraph @

gcc/testsuite/g++.dg/opt/typeinfo1.C

raw
1 // PR c++/61020
2 // { dg-options "-O2" }
3 // { dg-do run }
4
5 #include <typeinfo>
6
7 struct Base {
8 virtual ~Base() { }
9 };
10
11 struct Derived : public Base {
12 };
13
14 int compare(const Base& base)
15 {
16 return typeid(base) == typeid(typeid(Derived));
17 }
18
19 int main()
20 {
21 Base base;
22 Derived derived;
23
24 if (compare(base)) return 1;
25 if (compare(derived)) return 2;
26 return 0;
27 }