PR libstdc++/83134 Ensure std::__not_ converts B::value to bool

Backport from mainline
2017-11-23  Jonathan Wakely  <jwakely@redhat.com>

	PR libstdc++/83134
	* include/std/type_traits (__not_): Explicitly convert to bool.
	* testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error.
	* testsuite/20_util/logical_traits/83134.cc: New test.
	* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust
	dg-error.
	* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
	Likewise.

From-SVN: r255329
This commit is contained in:
Jonathan Wakely 2017-12-01 17:12:23 +00:00 committed by Jonathan Wakely
parent 526e9a2a50
commit 2a8f244b91
6 changed files with 54 additions and 13 deletions

View File

@ -1,5 +1,17 @@
2017-12-01 Jonathan Wakely <jwakely@redhat.com>
Backport from mainline
2017-11-23 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/83134
* include/std/type_traits (__not_): Explicitly convert to bool.
* testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error.
* testsuite/20_util/logical_traits/83134.cc: New test.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust
dg-error.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
Likewise.
Backport from mainline
2017-12-01 Jonathan Wakely <jwakely@redhat.com>

View File

@ -151,10 +151,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Pp>
struct __not_
: public integral_constant<bool, !_Pp::value>
: public __bool_constant<!bool(_Pp::value)>
{ };
#if __cplusplus > 201402L
#if __cplusplus >= 201703L
#define __cpp_lib_logical_traits 201510
@ -174,18 +174,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ };
template<typename... _Bn>
inline constexpr bool conjunction_v
= conjunction<_Bn...>::value;
inline constexpr bool conjunction_v = conjunction<_Bn...>::value;
template<typename... _Bn>
inline constexpr bool disjunction_v
= disjunction<_Bn...>::value;
inline constexpr bool disjunction_v = disjunction<_Bn...>::value;
template<typename _Pp>
inline constexpr bool negation_v
= negation<_Pp>::value;
inline constexpr bool negation_v = negation<_Pp>::value;
#endif
#endif // C++17
// For several sfinae-friendly trait implementations we transport both the
// result information (as the member type) and the failure information (no

View File

@ -18,7 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-error "static assertion failed" "" { target *-*-* } 2259 }
// { dg-error "declval.. must not be used" "" { target *-*-* } 0 }
#include <utility>

View File

@ -0,0 +1,32 @@
// Copyright (C) 2017 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/>.
// { dg-options "-std=gnu++17" }
// { dg-do compile { target c++1z } }
#include <type_traits>
struct X {
constexpr operator bool() const { return false; }
constexpr bool operator!() const = delete;
};
struct Y {
static constexpr X value{};
};
static_assert(std::negation<Y>::value); // PR libstdc++/83134

View File

@ -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 *-*-* } 1924 }
// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1921 }

View File

@ -47,5 +47,5 @@ void test01()
// { dg-error "required from here" "" { target *-*-* } 39 }
// { dg-error "required from here" "" { target *-*-* } 41 }
// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1820 }
// { dg-error "declaration of" "" { target *-*-* } 1777 }
// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1817 }
// { dg-error "declaration of" "" { target *-*-* } 1774 }