From: Jonathan Wakely Date: Thu, 23 Nov 2017 21:35:27 +0000 (+0000) Subject: PR libstdc++/83134 Ensure std::__not_ converts B::value to bool X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4b9840f230d4f8f4964639f776073821672fb1a7;p=gcc.git PR libstdc++/83134 Ensure std::__not_ converts B::value to bool 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: r255122 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c17581b3314..099881afad1 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,14 @@ +2017-11-23 Jonathan Wakely + + 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. + 2017-11-22 Jonathan Wakely PR go/83102 diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 7eca08c1a50..723c137f5b9 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -151,10 +151,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct __not_ - : public integral_constant + : public __bool_constant { }; -#if __cplusplus > 201402L +#if __cplusplus >= 201703L #define __cpp_lib_logical_traits 201510 @@ -174,18 +174,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { }; template - inline constexpr bool conjunction_v - = conjunction<_Bn...>::value; + inline constexpr bool conjunction_v = conjunction<_Bn...>::value; template - inline constexpr bool disjunction_v - = disjunction<_Bn...>::value; + inline constexpr bool disjunction_v = disjunction<_Bn...>::value; template - 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 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 17b41a007db..bc12719071e 100644 --- a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc +++ b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc @@ -18,7 +18,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-error "static assertion failed" "" { target *-*-* } 2093 } +// { dg-error "declval.. must not be used" "" { target *-*-* } 0 } #include diff --git a/libstdc++-v3/testsuite/20_util/logical_traits/83134.cc b/libstdc++-v3/testsuite/20_util/logical_traits/83134.cc new file mode 100644 index 00000000000..3595e64e977 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/logical_traits/83134.cc @@ -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 +// . + +// { dg-options "-std=gnu++17" } +// { dg-do compile { target c++17 } } + +#include + +struct X { + constexpr operator bool() const { return false; } + constexpr bool operator!() const = delete; +}; + +struct Y { + static constexpr X value{}; +}; + +static_assert(std::negation::value); // PR libstdc++/83134 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 308155383f0..05bef35c03b 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 *-*-* } 1760 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1757 } 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 412608e5669..25240a2cf05 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,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 *-*-* } 1656 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1653 }