]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/18_support/type_info/fundamental.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 18_support / type_info / fundamental.cc
1 // { dg-do run { target c++11 } }
2 // { dg-require-effective-target dfp }
3 // { dg-require-effective-target rtti }
4
5 // 2011-02-23 Benjamin Kosnik <bkoz@redhat.com>
6 //
7 // Copyright (C) 2011-2023 Free Software Foundation, Inc.
8 //
9 // This file is part of the GNU ISO C++ Library. This library is free
10 // software; you can redistribute it and/or modify it under the
11 // terms of the GNU General Public License as published by the
12 // Free Software Foundation; either version 3, or (at your option)
13 // any later version.
14
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19
20 // You should have received a copy of the GNU General Public License along
21 // with this library; see the file COPYING3. If not see
22 // <http://www.gnu.org/licenses/>.
23
24 #include <string>
25 #include <typeinfo>
26 #include <decimal/decimal>
27
28 template<typename _Tp>
29 std::string
30 gen_type_info()
31 {
32 std::string s1 = typeid(_Tp).name();
33 std::string s2 = typeid(_Tp*).name();
34 std::string s3 = typeid(const _Tp*).name();
35 return std::max(std::max(s1, s2), s3);
36 }
37
38 // libstdc++/43622, others
39 int main()
40 {
41 gen_type_info<bool>();
42 gen_type_info<char>();
43 gen_type_info<signed char>();
44 gen_type_info<unsigned char>();
45 gen_type_info<short>();
46 gen_type_info<unsigned short>();
47 gen_type_info<int>();
48 gen_type_info<unsigned int>();
49 gen_type_info<long>();
50 gen_type_info<unsigned long>();
51 gen_type_info<long long>();
52 gen_type_info<unsigned long long>();
53 gen_type_info<wchar_t>();
54 #ifdef _GLIBCXX_USE_CHAR8_T
55 gen_type_info<char8_t>();
56 #endif
57 gen_type_info<char16_t>();
58 gen_type_info<char32_t>();
59
60 gen_type_info<float>();
61 gen_type_info<double>();
62 gen_type_info<long double>();
63
64 gen_type_info<void>();
65
66 gen_type_info<std::nullptr_t>();
67
68 // decimal
69 gen_type_info<std::decimal::decimal32>();
70 gen_type_info<std::decimal::decimal64>();
71 gen_type_info<std::decimal::decimal128>();
72
73 // attributes
74 #if 0
75 typedef int ti_type __attribute__((__mode__(TI)));
76 gen_type_info<ti_type>();
77
78 typedef float tf_type __attribute__((__mode__(TF)));
79 gen_type_info<tf_type>();
80 #endif
81
82 return 0;
83 }