aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2018-07-04 10:03:18 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2018-07-04 10:03:18 +0100
commite9029d55f24c824698de277abc1961e4673512db (patch)
tree8ed81f56279a8f78b37a8d052c88e432d1a44e8c
parent90fc44ecfa4741a055ec3d35722e2624c2231f98 (diff)
downloadgcc-e9029d55f24c824698de277abc1961e4673512db.zip
gcc-e9029d55f24c824698de277abc1961e4673512db.tar.gz
gcc-e9029d55f24c824698de277abc1961e4673512db.tar.bz2
PR libstdc++/86398 fix std::is_trivially_constructible regression
The intrinsic doesn't check for allowed conversions between scalar types, so restore the std::is_constructible check. Also make some trivial whitespace changes. PR libstdc++/86398 * include/std/type_traits (is_trivially_constructible): Check is_constructible before __is_trivially_constructible. * testsuite/20_util/is_trivially_constructible/value.cc: Add more tests, including negative cases. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Use zero for dg-error lineno. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Likewise. From-SVN: r262379
-rw-r--r--libstdc++-v3/ChangeLog10
-rw-r--r--libstdc++-v3/include/std/type_traits21
-rw-r--r--libstdc++-v3/testsuite/20_util/is_trivially_constructible/value.cc138
-rw-r--r--libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc3
5 files changed, 100 insertions, 74 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index e3211bc..fa92b4b 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,15 @@
2018-07-04 Jonathan Wakely <jwakely@redhat.com>
+ PR libstdc++/86398
+ * include/std/type_traits (is_trivially_constructible): Check
+ is_constructible before __is_trivially_constructible.
+ * testsuite/20_util/is_trivially_constructible/value.cc: Add more
+ tests, including negative cases.
+ * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Use
+ zero for dg-error lineno.
+ * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
+ Likewise.
+
* include/std/bit (__rotl, __rotr): Avoid branch.
(_If_is_unsigned_integer): Use remove_cv_t.
* testsuite/26_numerics/bit/bitops.count/popcount.cc: New.
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index accea6d..4df82bf 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -1136,7 +1136,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// is_trivially_constructible
template<typename _Tp, typename... _Args>
struct is_trivially_constructible
- : public __bool_constant<__is_trivially_constructible(_Tp, _Args...)>
+ : public __and_<is_constructible<_Tp, _Args...>, __bool_constant<
+ __is_trivially_constructible(_Tp, _Args...)>>::type
{ };
/// is_trivially_default_constructible
@@ -1159,21 +1160,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp>
struct __is_implicitly_default_constructible_impl
- : public __do_is_implicitly_default_constructible_impl
- {
- typedef decltype(__test(declval<_Tp>())) type;
- };
+ : public __do_is_implicitly_default_constructible_impl
+ {
+ typedef decltype(__test(declval<_Tp>())) type;
+ };
template<typename _Tp>
struct __is_implicitly_default_constructible_safe
- : public __is_implicitly_default_constructible_impl<_Tp>::type
- { };
+ : public __is_implicitly_default_constructible_impl<_Tp>::type
+ { };
template <typename _Tp>
struct __is_implicitly_default_constructible
- : public __and_<is_default_constructible<_Tp>,
- __is_implicitly_default_constructible_safe<_Tp>>
- { };
+ : public __and_<is_default_constructible<_Tp>,
+ __is_implicitly_default_constructible_safe<_Tp>>
+ { };
/// is_trivially_copy_constructible
diff --git a/libstdc++-v3/testsuite/20_util/is_trivially_constructible/value.cc b/libstdc++-v3/testsuite/20_util/is_trivially_constructible/value.cc
index d2ab27d..f260c2a 100644
--- a/libstdc++-v3/testsuite/20_util/is_trivially_constructible/value.cc
+++ b/libstdc++-v3/testsuite/20_util/is_trivially_constructible/value.cc
@@ -44,124 +44,140 @@ void test01()
using std::is_trivially_constructible;
using namespace __gnu_test;
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
int>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
int, int>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
int, int&>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
int, int&&>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
int, const int&>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
+ int, void*>(false), "PR 86398");
+ static_assert(test_property<is_trivially_constructible,
+ int, int*>(false), "PR 86398");
+ static_assert(test_property<is_trivially_constructible,
+ int, const int*>(false), "PR 86398");
+ static_assert(test_property<is_trivially_constructible,
+ int*, void*>(false), "PR 86398");
+ static_assert(test_property<is_trivially_constructible,
+ int*, const int*>(false), "PR 86398");
+ static_assert(test_property<is_trivially_constructible,
+ int&, const int>(false), "");
+ static_assert(test_property<is_trivially_constructible,
+ const int&, int>(true), "");
+ static_assert(test_property<is_trivially_constructible,
+ const int&, int&>(true), "");
+ static_assert(test_property<is_trivially_constructible,
+ const int*, int*>(true), "");
+ static_assert(test_property<is_trivially_constructible,
PolymorphicClass>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
PolymorphicClass, PolymorphicClass>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
PolymorphicClass, PolymorphicClass&>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
PolymorphicClass, PolymorphicClass&&>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
PolymorphicClass, const PolymorphicClass&>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
TType>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
TType, TType>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
TType, TType&>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
TType, TType&&>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
TType, const TType&>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
TType, int, int>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
PODType>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
PODType, PODType>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
PODType, PODType&>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
PODType, PODType&&>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
PODType, const PODType&>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
PODType, int, int>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
NType>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
SLType>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
LType>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
LType, int>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
construct::DelDef>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
construct::Abstract>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
construct::Ellipsis>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
construct::DelEllipsis>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
construct::Any>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
construct::DelCopy>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
construct::DelCopy, const construct::DelCopy&>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
construct::DelDtor>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
construct::Nontrivial>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
construct::UnusualCopy>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
CopyConsOnlyType>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
CopyConsOnlyType, CopyConsOnlyType>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
CopyConsOnlyType, CopyConsOnlyType&>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
CopyConsOnlyType, CopyConsOnlyType&&>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
CopyConsOnlyType, const CopyConsOnlyType&>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
MoveConsOnlyType>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
MoveConsOnlyType, MoveConsOnlyType>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
MoveConsOnlyType, MoveConsOnlyType&>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
MoveConsOnlyType, MoveConsOnlyType&&>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
MoveConsOnlyType, const MoveConsOnlyType&>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
ClassType, DerivedType>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
ClassType, DerivedType&>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
ClassType, DerivedType&&>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
ClassType, const DerivedType&>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
HasTemplateCCtor>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
HasTemplateCCtor, HasTemplateCCtor>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
HasTemplateCCtor, const HasTemplateCCtor&>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
MoveOnly>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
MoveOnly, MoveOnly>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
MoveOnly, MoveOnly&>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
MoveOnly, MoveOnly&&>(true), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
MoveOnly, const MoveOnly&>(false), "");
- static_assert(test_property<is_trivially_constructible,
+ static_assert(test_property<is_trivially_constructible,
MoveOnly2>(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 1380fc5..53cdf61 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
@@ -47,4 +47,4 @@ void test01()
// { dg-error "required from here" "" { target *-*-* } 39 }
// { dg-error "required from here" "" { target *-*-* } 41 }
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1825 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 0 }
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 cbc5300..ec5b611 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
@@ -47,5 +47,4 @@ void test01()
// { dg-error "required from here" "" { target *-*-* } 39 }
// { dg-error "required from here" "" { target *-*-* } 41 }
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1708 }
-
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 0 }