From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 4582A3858419; Sat, 24 Sep 2022 00:07:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4582A3858419 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663978048; bh=8+dcosWLlEs4KuN9Z6uUOpvHiPkxPqqK1XAmOVBsceU=; h=From:To:Subject:Date:From; b=CfleQ27QXVeADzQw8T2arW4QaJgUwK2yiRSNQ6ASFqjSLy2ZOAOcBcPZPqyW81zAP Sm+dOyr2FR5shzaHZdEGIJkwcEyzHzpNRgOixsfu1Z48J23r32j4HEXVm3odYOQsqd 8VJxA+xmCL6ggZldKED4U4OeU03LDTqqPxI53j98= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-2826] libstdc++: Add test for type traits not having friend access X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 71c828f84572d933979468baf2cf744180258ee4 X-Git-Newrev: 5924c7d584640665db174c7545ae6c2b784af27c Message-Id: <20220924000728.4582A3858419@sourceware.org> Date: Sat, 24 Sep 2022 00:07:28 +0000 (GMT) List-Id: https://gcc.gnu.org/g:5924c7d584640665db174c7545ae6c2b784af27c commit r13-2826-g5924c7d584640665db174c7545ae6c2b784af27c Author: Jonathan Wakely Date: Fri Sep 23 22:04:24 2022 +0100 libstdc++: Add test for type traits not having friend access This ensures that the std::is_assignable and std::is_assignable_v traits are evaluated "in a context unrelated" to the argument types. libstdc++-v3/ChangeLog: * testsuite/20_util/is_assignable/requirements/access.cc: New test. Diff: --- .../20_util/is_assignable/requirements/access.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libstdc++-v3/testsuite/20_util/is_assignable/requirements/access.cc b/libstdc++-v3/testsuite/20_util/is_assignable/requirements/access.cc new file mode 100644 index 00000000000..a96fba654cd --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_assignable/requirements/access.cc @@ -0,0 +1,22 @@ +// { dg-do compile { target c++11 } } + +#include + +class S { + operator int(); + friend void g(); // #1 +}; + +void +g() +{ + int i = 0; + S s; + i = s; // this works, because we're inside a friend. + + // But the traits are evaluated in "a context unrelated to either type". + static_assert( ! std::is_assignable::value, "unfriendly"); +#if __cplusplus >= 201703L + static_assert( ! std::is_assignable_v, "unfriendly"); +#endif +}