1 // { dg-do run { target c++11 } } 2 3 // 2010-09-21 Paolo Carlini <paolo.carlini@oracle.com> 4 // 5 // Copyright (C) 2010-2018 Free Software Foundation, Inc. 6 // 7 // This file is part of the GNU ISO C++ Library. This library is free 8 // software; you can redistribute it and/or modify it under the 9 // terms of the GNU General Public License as published by the 10 // Free Software Foundation; either version 3, or (at your option) 11 // any later version. 12 13 // This library is distributed in the hope that it will be useful, 14 // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 // GNU General Public License for more details. 17 18 // You should have received a copy of the GNU General Public License along 19 // with this library; see the file COPYING3. If not see 20 // <http://www.gnu.org/licenses/>. 21 22 #include <typeinfo> 23 #include <testsuite_hooks.h> 24 test01()25void test01() 26 { 27 using namespace std; 28 29 class Abraca { }; 30 Abraca a1, a2_; 31 32 typedef const Abraca cAbraca; 33 cAbraca a2 = a2_; 34 35 class Dabra { }; 36 Dabra d1; 37 38 const type_info& to01 = typeid(int); 39 const type_info& to02 = typeid(double); 40 VERIFY( to01 != to02 ); 41 VERIFY( to01.hash_code() != to02.hash_code() ); 42 43 const type_info& to03 = typeid(a1); 44 const type_info& to04 = typeid(a2); 45 VERIFY( to03 == to04 ); 46 VERIFY( to03.hash_code() == to04.hash_code() ); 47 48 const type_info& to05 = typeid(Abraca); 49 const type_info& to06 = typeid(cAbraca); 50 VERIFY( to05 == to06 ); 51 VERIFY( to05.hash_code() == to06.hash_code() ); 52 53 const type_info& to07 = typeid(Abraca); 54 const type_info& to08 = typeid(a2); 55 VERIFY( to07 == to08 ); 56 VERIFY( to07.hash_code() == to08.hash_code() ); 57 58 const type_info& to09 = typeid(Abraca); 59 const type_info& to10 = typeid(const Abraca&); 60 VERIFY( to09 == to10 ); 61 VERIFY( to09.hash_code() == to10.hash_code() ); 62 63 const type_info& to11 = typeid(Abraca); 64 const type_info& to12 = typeid(Dabra); 65 VERIFY( to11 != to12 ); 66 VERIFY( to11.hash_code() != to12.hash_code() ); 67 68 const type_info& to13 = typeid(a1); 69 const type_info& to14 = typeid(d1); 70 VERIFY( to13 != to14 ); 71 VERIFY( to13.hash_code() != to14.hash_code() ); 72 } 73 main()74int main() 75 { 76 test01(); 77 return 0; 78 } 79