aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2019-06-06 13:13:47 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2019-06-06 13:13:47 +0100
commit209ee62421fdeb177bdac29e670bc9b930bef4a3 (patch)
treea96dc1ea03015db9f91d556938797031d7cef0ba
parent061a745005d69e44d6ff50e3ee7fd5b21194c6ac (diff)
downloadgcc-209ee62421fdeb177bdac29e670bc9b930bef4a3.zip
gcc-209ee62421fdeb177bdac29e670bc9b930bef4a3.tar.gz
gcc-209ee62421fdeb177bdac29e670bc9b930bef4a3.tar.bz2
Remove redundant static assertions in [meta.unary.prop] traits
The type property predicates that are implemented by a compiler builtin already do the right checks in the compiler. The checks for complete type or unbounded arrays were wrong for these types anyway. * include/std/type_traits (is_empty, is_polymorphic, is_final) (is_abstract, is_aggregate): Remove static_assert. * testsuite/20_util/is_abstract/incomplete_neg.cc: Check for error from builtin only. * testsuite/20_util/is_aggregate/incomplete_neg.cc: Likewise. Add missing -std=gnu++17 option. * testsuite/20_util/is_empty/incomplete_neg.cc: New test. * testsuite/20_util/is_final/incomplete_neg.cc: New test. * testsuite/20_util/is_polymorphic/incomplete_neg.cc: Check for error from builtin only. From-SVN: r272000
-rw-r--r--libstdc++-v3/ChangeLog11
-rw-r--r--libstdc++-v3/include/std/type_traits25
-rw-r--r--libstdc++-v3/testsuite/20_util/is_abstract/incomplete_neg.cc7
-rw-r--r--libstdc++-v3/testsuite/20_util/is_aggregate/incomplete_neg.cc6
-rw-r--r--libstdc++-v3/testsuite/20_util/is_empty/incomplete_neg.cc30
-rw-r--r--libstdc++-v3/testsuite/20_util/is_final/incomplete_neg.cc30
-rw-r--r--libstdc++-v3/testsuite/20_util/is_polymorphic/incomplete_neg.cc7
7 files changed, 88 insertions, 28 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 283c6b9..3dd82b6 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,16 @@
2019-06-06 Jonathan Wakely <jwakely@redhat.com>
+ * include/std/type_traits (is_empty, is_polymorphic, is_final)
+ (is_abstract, is_aggregate): Remove static_assert.
+ * testsuite/20_util/is_abstract/incomplete_neg.cc: Check for error
+ from builtin only.
+ * testsuite/20_util/is_aggregate/incomplete_neg.cc: Likewise. Add
+ missing -std=gnu++17 option.
+ * testsuite/20_util/is_empty/incomplete_neg.cc: New test.
+ * testsuite/20_util/is_final/incomplete_neg.cc: New test.
+ * testsuite/20_util/is_polymorphic/incomplete_neg.cc: Check for error
+ from builtin only.
+
* testsuite/18_support/set_terminate.cc: Do not run for C++98 mode.
* testsuite/18_support/set_unexpected.cc: Likewise.
* testsuite/20_util/is_nothrow_invocable/value.cc: Test converting to
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 78a113a..e53d3c8 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -746,19 +746,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp>
struct is_empty
: public integral_constant<bool, __is_empty(_Tp)>
- {
- static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
- "template argument must be a complete class or an unbounded array");
- };
+ { };
/// is_polymorphic
template<typename _Tp>
struct is_polymorphic
: public integral_constant<bool, __is_polymorphic(_Tp)>
- {
- static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
- "template argument must be a complete class or an unbounded array");
- };
+ { };
#if __cplusplus >= 201402L
#define __cpp_lib_is_final 201402L
@@ -766,20 +760,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp>
struct is_final
: public integral_constant<bool, __is_final(_Tp)>
- {
- static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
- "template argument must be a complete class or an unbounded array");
- };
+ { };
#endif
/// is_abstract
template<typename _Tp>
struct is_abstract
: public integral_constant<bool, __is_abstract(_Tp)>
- {
- static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
- "template argument must be a complete class or an unbounded array");
- };
+ { };
template<typename _Tp,
bool = is_arithmetic<_Tp>::value>
@@ -3174,10 +3162,7 @@ template <typename _From, typename _To>
template<typename _Tp>
struct is_aggregate
: bool_constant<__is_aggregate(remove_cv_t<_Tp>)>
- {
- static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
- "template argument must be a complete class or an unbounded array");
- };
+ { };
/// is_aggregate_v
template<typename _Tp>
diff --git a/libstdc++-v3/testsuite/20_util/is_abstract/incomplete_neg.cc b/libstdc++-v3/testsuite/20_util/is_abstract/incomplete_neg.cc
index 94f4ecd..a2a73d0 100644
--- a/libstdc++-v3/testsuite/20_util/is_abstract/incomplete_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/is_abstract/incomplete_neg.cc
@@ -1,7 +1,5 @@
// { dg-do compile { target c++11 } }
-// { dg-prune-output "invalid use of incomplete type" }
-// { dg-prune-output "must be a complete" }
-//
+
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -19,6 +17,9 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
+// Expect the compiler builtin to do the completeness check.
+// { dg-error "incomplete type" "" { target *-*-* } 0 }
+
#include <type_traits>
class X;
diff --git a/libstdc++-v3/testsuite/20_util/is_aggregate/incomplete_neg.cc b/libstdc++-v3/testsuite/20_util/is_aggregate/incomplete_neg.cc
index 8a3dd55..eff3f64 100644
--- a/libstdc++-v3/testsuite/20_util/is_aggregate/incomplete_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/is_aggregate/incomplete_neg.cc
@@ -1,5 +1,6 @@
+// { dg-options "-std=gnu++17" }
// { dg-do compile { target c++17 } }
-//
+
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -17,7 +18,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// { dg-error "must be a complete class" "" { target *-*-* } 0 }
+// Expect the compiler builtin to do the completeness check.
+// { dg-error "incomplete type" "" { target *-*-* } 0 }
#include <type_traits>
diff --git a/libstdc++-v3/testsuite/20_util/is_empty/incomplete_neg.cc b/libstdc++-v3/testsuite/20_util/is_empty/incomplete_neg.cc
new file mode 100644
index 0000000..3bacefb
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/is_empty/incomplete_neg.cc
@@ -0,0 +1,30 @@
+// { dg-do compile { target c++11 } }
+
+// Copyright (C) 2019 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/>.
+
+// Expect the compiler builtin to do the completeness check.
+// { dg-error "incomplete type" "" { target *-*-* } 0 }
+
+#include <type_traits>
+
+class X;
+
+void test01()
+{
+ std::is_empty<X>(); // { dg-error "required from here" }
+}
diff --git a/libstdc++-v3/testsuite/20_util/is_final/incomplete_neg.cc b/libstdc++-v3/testsuite/20_util/is_final/incomplete_neg.cc
new file mode 100644
index 0000000..0727c09
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/is_final/incomplete_neg.cc
@@ -0,0 +1,30 @@
+// { dg-do compile { target c++14 } }
+
+// Copyright (C) 2019 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/>.
+
+// Expect the compiler builtin to do the completeness check.
+// { dg-error "incomplete type" "" { target *-*-* } 0 }
+
+#include <type_traits>
+
+class X;
+
+void test01()
+{
+ std::is_final<X>(); // { dg-error "required from here" }
+}
diff --git a/libstdc++-v3/testsuite/20_util/is_polymorphic/incomplete_neg.cc b/libstdc++-v3/testsuite/20_util/is_polymorphic/incomplete_neg.cc
index 8cd1b40..618c4fa 100644
--- a/libstdc++-v3/testsuite/20_util/is_polymorphic/incomplete_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/is_polymorphic/incomplete_neg.cc
@@ -1,7 +1,5 @@
// { dg-do compile { target c++11 } }
-// { dg-prune-output "invalid use of incomplete type" }
-// { dg-prune-output "must be a complete" }
-//
+
// Copyright (C) 2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -19,6 +17,9 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
+// Expect the compiler builtin to do the completeness check.
+// { dg-error "incomplete type" "" { target *-*-* } 0 }
+
#include <type_traits>
class X;