summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoremsr <emsr@138bc75d-0d04-0410-961f-82ee72b054a4>2014-10-03 13:50:20 +0000
committeremsr <emsr@138bc75d-0d04-0410-961f-82ee72b054a4>2014-10-03 13:50:20 +0000
commit0b28e85cc6fa6f10c51cfa6a212169ac4eef47a0 (patch)
treea89a8ba37e371ca38d11ecc0ff257509db88ade5
parentecddc70ebcac131c126752ff7e09c3587b52f921 (diff)
downloadppe42-gcc-0b28e85cc6fa6f10c51cfa6a212169ac4eef47a0.tar.gz
ppe42-gcc-0b28e85cc6fa6f10c51cfa6a212169ac4eef47a0.zip
2014-10-03 Edward Smith-Rowland <3dw4rd@verizon.net>
* include/std/type_traits: Add is_final<> type trait for C++14. * testsuite/util/testsuite_tr1.h: Add FinalType. * testsuite/20_util/is_final/requirements/ explicit_instantiation.cc: New. * testsuite/20_util/is_final/requirements/typedefs.cc: New. * testsuite/20_util/is_final/value.cc: New. * testsuite/20_util/declval/requirements/1_neg.cc: Adjust. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@215850 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog12
-rw-r--r--libstdc++-v3/include/std/type_traits8
-rw-r--r--libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/is_final/requirements/explicit_instantiation.cc29
-rw-r--r--libstdc++-v3/testsuite/20_util/is_final/requirements/typedefs.cc34
-rw-r--r--libstdc++-v3/testsuite/20_util/is_final/value.cc35
-rw-r--r--libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc4
-rw-r--r--libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc4
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_tr1.h4
9 files changed, 127 insertions, 5 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 90feb44e0a5..96ac24ee719 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,15 @@
+2014-10-03 Edward Smith-Rowland <3dw4rd@verizon.net>
+
+ * include/std/type_traits: Add is_final<> type trait for C++14.
+ * testsuite/util/testsuite_tr1.h: Add FinalType.
+ * testsuite/20_util/is_final/requirements/
+ explicit_instantiation.cc: New.
+ * testsuite/20_util/is_final/requirements/typedefs.cc: New.
+ * testsuite/20_util/is_final/value.cc: New.
+ * testsuite/20_util/declval/requirements/1_neg.cc: Adjust.
+ * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust.
+ * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Adjust.
+
2014-10-02 Tim Shen <timshen@google.com>
PR libstdc++/63199
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 1ff2e625a73..e898c9f4e53 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -634,6 +634,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: public integral_constant<bool, __is_polymorphic(_Tp)>
{ };
+#if __cplusplus > 201103L
+ /// is_final
+ template<typename _Tp>
+ struct is_final
+ : public integral_constant<bool, __is_final(_Tp)>
+ { };
+#endif
+
/// is_abstract
template<typename _Tp>
struct is_abstract
diff --git a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc
index 04e6b711906..a0e3d9300e2 100644
--- a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc
@@ -19,7 +19,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// { dg-error "static assertion failed" "" { target *-*-* } 2036 }
+// { dg-error "static assertion failed" "" { target *-*-* } 2044 }
#include <utility>
diff --git a/libstdc++-v3/testsuite/20_util/is_final/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_final/requirements/explicit_instantiation.cc
new file mode 100644
index 00000000000..c5d44e6bcfd
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/is_final/requirements/explicit_instantiation.cc
@@ -0,0 +1,29 @@
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// 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/>.
+
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include <type_traits>
+
+namespace std
+{
+ typedef short test_type;
+ template struct is_final<test_type>;
+}
diff --git a/libstdc++-v3/testsuite/20_util/is_final/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_final/requirements/typedefs.cc
new file mode 100644
index 00000000000..b07d90becaa
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/is_final/requirements/typedefs.cc
@@ -0,0 +1,34 @@
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// 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/>.
+
+//
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include <type_traits>
+
+void test01()
+{
+ // Check for required typedefs
+ typedef std::is_final<int> test_type;
+ typedef test_type::value_type value_type;
+ typedef test_type::type type;
+ typedef test_type::type::value_type type_value_type;
+ typedef test_type::type::type type_type;
+}
diff --git a/libstdc++-v3/testsuite/20_util/is_final/value.cc b/libstdc++-v3/testsuite/20_util/is_final/value.cc
new file mode 100644
index 00000000000..281c1ab6d7f
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/is_final/value.cc
@@ -0,0 +1,35 @@
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// Copyright (C) 2011-2014 Free Software Foundation, Inc.
+//
+// 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 <type_traits>
+#include <testsuite_tr1.h>
+
+void test01()
+{
+ using std::is_final;
+ using namespace __gnu_test;
+
+ // Positive test.
+ static_assert(test_category<is_final, FinalType>(true), "");
+
+ // Negative tests.
+ static_assert(test_category<is_final, ClassType>(false), "");
+ static_assert(test_category<is_final, DerivedType>(false), "");
+}
diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
index d711546050d..feb9c02b086 100644
--- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
@@ -48,5 +48,5 @@ void test01()
// { dg-error "required from here" "" { target *-*-* } 40 }
// { dg-error "required from here" "" { target *-*-* } 42 }
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1747 }
-// { dg-error "declaration of" "" { target *-*-* } 1711 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1755 }
+// { dg-error "declaration of" "" { target *-*-* } 1719 }
diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
index c77205be01d..ad4eb744d12 100644
--- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
@@ -48,5 +48,5 @@ void test01()
// { dg-error "required from here" "" { target *-*-* } 40 }
// { dg-error "required from here" "" { target *-*-* } 42 }
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1650 }
-// { dg-error "declaration of" "" { target *-*-* } 1614 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1658 }
+// { dg-error "declaration of" "" { target *-*-* } 1622 }
diff --git a/libstdc++-v3/testsuite/util/testsuite_tr1.h b/libstdc++-v3/testsuite/util/testsuite_tr1.h
index aa80a214617..6e962961b16 100644
--- a/libstdc++-v3/testsuite/util/testsuite_tr1.h
+++ b/libstdc++-v3/testsuite/util/testsuite_tr1.h
@@ -100,6 +100,10 @@ namespace __gnu_test
class DerivedType : public ClassType { };
+#if __cplusplus >= 201103L
+ class FinalType final : public DerivedType { };
+#endif
+
enum EnumType { e0 };
struct ConvType
OpenPOWER on IntegriCloud