PR c/77336 - -Wsuggest-attribute=format warning overly simplistic
[official-gcc.git] / libstdc++-v3 / testsuite / 18_support / type_info / hash_code.cc
blob8758222b20e6600ec8723c80862c50d39843c673
1 // { dg-do run { target c++11 } }
3 // 2010-09-21 Paolo Carlini <paolo.carlini@oracle.com>
4 //
5 // Copyright (C) 2010-2016 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.
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.
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/>.
22 #include <typeinfo>
23 #include <testsuite_hooks.h>
25 void test01()
27 bool test __attribute__((unused)) = true;
28 using namespace std;
30 class Abraca { };
31 Abraca a1, a2_;
33 typedef const Abraca cAbraca;
34 cAbraca a2 = a2_;
36 class Dabra { };
37 Dabra d1;
39 const type_info& to01 = typeid(int);
40 const type_info& to02 = typeid(double);
41 VERIFY( to01 != to02 );
42 VERIFY( to01.hash_code() != to02.hash_code() );
44 const type_info& to03 = typeid(a1);
45 const type_info& to04 = typeid(a2);
46 VERIFY( to03 == to04 );
47 VERIFY( to03.hash_code() == to04.hash_code() );
49 const type_info& to05 = typeid(Abraca);
50 const type_info& to06 = typeid(cAbraca);
51 VERIFY( to05 == to06 );
52 VERIFY( to05.hash_code() == to06.hash_code() );
54 const type_info& to07 = typeid(Abraca);
55 const type_info& to08 = typeid(a2);
56 VERIFY( to07 == to08 );
57 VERIFY( to07.hash_code() == to08.hash_code() );
59 const type_info& to09 = typeid(Abraca);
60 const type_info& to10 = typeid(const Abraca&);
61 VERIFY( to09 == to10 );
62 VERIFY( to09.hash_code() == to10.hash_code() );
64 const type_info& to11 = typeid(Abraca);
65 const type_info& to12 = typeid(Dabra);
66 VERIFY( to11 != to12 );
67 VERIFY( to11.hash_code() != to12.hash_code() );
69 const type_info& to13 = typeid(a1);
70 const type_info& to14 = typeid(d1);
71 VERIFY( to13 != to14 );
72 VERIFY( to13.hash_code() != to14.hash_code() );
75 int main()
77 test01();
78 return 0;