summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/18_support/type_info
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/18_support/type_info
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libstdc++-v3/testsuite/18_support/type_info')
-rw-r--r--libstdc++-v3/testsuite/18_support/type_info/fundamental.cc79
-rw-r--r--libstdc++-v3/testsuite/18_support/type_info/hash_code.cc79
2 files changed, 158 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/18_support/type_info/fundamental.cc b/libstdc++-v3/testsuite/18_support/type_info/fundamental.cc
new file mode 100644
index 000000000..00c64b8cf
--- /dev/null
+++ b/libstdc++-v3/testsuite/18_support/type_info/fundamental.cc
@@ -0,0 +1,79 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-effective-target dfp }
+
+// 2011-02-23 Benjamin Kosnik <bkoz@redhat.com>
+//
+// Copyright (C) 2011 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <string>
+#include <typeinfo>
+#include <decimal/decimal>
+
+template<typename _Tp>
+ std::string
+ gen_type_info()
+ {
+ std::string s1 = typeid(_Tp).name();
+ std::string s2 = typeid(_Tp*).name();
+ std::string s3 = typeid(const _Tp*).name();
+ return std::max(std::max(s1, s2), s3);
+ }
+
+// libstdc++/43622, others
+int main()
+{
+ gen_type_info<bool>();
+ gen_type_info<char>();
+ gen_type_info<signed char>();
+ gen_type_info<unsigned char>();
+ gen_type_info<short>();
+ gen_type_info<unsigned short>();
+ gen_type_info<int>();
+ gen_type_info<unsigned int>();
+ gen_type_info<long>();
+ gen_type_info<unsigned long>();
+ gen_type_info<long long>();
+ gen_type_info<unsigned long long>();
+ gen_type_info<wchar_t>();
+ gen_type_info<char16_t>();
+ gen_type_info<char32_t>();
+
+ gen_type_info<float>();
+ gen_type_info<double>();
+ gen_type_info<long double>();
+
+ gen_type_info<void>();
+
+ gen_type_info<std::nullptr_t>();
+
+ // decimal
+ gen_type_info<std::decimal::decimal32>();
+ gen_type_info<std::decimal::decimal64>();
+ gen_type_info<std::decimal::decimal128>();
+
+ // attributes
+#if 0
+ typedef int ti_type __attribute__((__mode__(TI)));
+ gen_type_info<ti_type>();
+
+ typedef float tf_type __attribute__((__mode__(TF)));
+ gen_type_info<tf_type>();
+#endif
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/18_support/type_info/hash_code.cc b/libstdc++-v3/testsuite/18_support/type_info/hash_code.cc
new file mode 100644
index 000000000..2d4c65bc5
--- /dev/null
+++ b/libstdc++-v3/testsuite/18_support/type_info/hash_code.cc
@@ -0,0 +1,79 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-09-21 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <typeinfo>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ class Abraca { };
+ Abraca a1, a2_;
+
+ typedef const Abraca cAbraca;
+ cAbraca a2 = a2_;
+
+ class Dabra { };
+ Dabra d1;
+
+ const type_info& to01 = typeid(int);
+ const type_info& to02 = typeid(double);
+ VERIFY( to01 != to02 );
+ VERIFY( to01.hash_code() != to02.hash_code() );
+
+ const type_info& to03 = typeid(a1);
+ const type_info& to04 = typeid(a2);
+ VERIFY( to03 == to04 );
+ VERIFY( to03.hash_code() == to04.hash_code() );
+
+ const type_info& to05 = typeid(Abraca);
+ const type_info& to06 = typeid(cAbraca);
+ VERIFY( to05 == to06 );
+ VERIFY( to05.hash_code() == to06.hash_code() );
+
+ const type_info& to07 = typeid(Abraca);
+ const type_info& to08 = typeid(a2);
+ VERIFY( to07 == to08 );
+ VERIFY( to07.hash_code() == to08.hash_code() );
+
+ const type_info& to09 = typeid(Abraca);
+ const type_info& to10 = typeid(const Abraca&);
+ VERIFY( to09 == to10 );
+ VERIFY( to09.hash_code() == to10.hash_code() );
+
+ const type_info& to11 = typeid(Abraca);
+ const type_info& to12 = typeid(Dabra);
+ VERIFY( to11 != to12 );
+ VERIFY( to11.hash_code() != to12.hash_code() );
+
+ const type_info& to13 = typeid(a1);
+ const type_info& to14 = typeid(d1);
+ VERIFY( to13 != to14 );
+ VERIFY( to13.hash_code() != to14.hash_code() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}