From patchwork Sat Sep 24 00:07:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1430 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp469425wrt; Fri, 23 Sep 2022 17:09:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5/pTRR6Gby87imBzPPvC+vMLVc1cpG4wJ0VZyOhQA9xqhpriCC6aymA0lYjwdchGap+y3V X-Received: by 2002:a17:907:7f13:b0:782:9f6f:edbc with SMTP id qf19-20020a1709077f1300b007829f6fedbcmr4881701ejc.544.1663978190255; Fri, 23 Sep 2022 17:09:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663978190; cv=none; d=google.com; s=arc-20160816; b=0l+0DlJ0Jr+CH7zsHDolZoBVNQF8kfr2pDYU/iJ8bFUF7iee2xdUU8js5AfCW8DBBb Tdkbt/IoitQ13HN4pEedWMW/4/HMpan3GNaQ6rl06ocGXmLSrcC4LTEHz+8HZbS85J5L rE/1OgfsvLTCMo6lif/cMxIlFrw9B2lzbOc/q4Ni8mvhZJTqGhrovFqLtj1Lg+UYDvCf iRZYEVJbp3D6r2X9WrVhoCuWvDwyVrbBJMUxzRjtWm5clLa+Yb/x21o8WLeCg/vjmvEv pxXKPqCVrTURnwvDeskuIScmfGz9f81iCoZvx4BLNrC6VM/rMFNHb3afTCzfHU3QFkV2 XC4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=bcgy6Gws4QQaFPKsf+rvcDemwRGgGW9doowNSVXQUhw=; b=AVqOzuH9VggBvZHkm2s0/C9PJK50gnR857nOFsdnWXGNJOFu0Lrk71qtVqAEuqhUGl kRjWOJz6GJC13zNS38vtSPYWXLpG6Ugi9b5ggPRmexodoDnH/J0Lm91P7RmVzAmM9bfV D2aDzSBN9lxtOFFHHQAXjnuEpbBgqKyVHLdbstCZNRljB5bPUwrpEMM1QsbtfOJkDUyN T4WBYsUr7w/qKIAKVJOItkh/nE6WS6yt4gJ7mhOllyZpX2XTtS+VlD2vmB/oqEPXsbf5 3xhZAqfN+JH5mARSRWEA8U9we4f4Imxuj7A78ht14/WHs39SVL9wVaZD/pfZ8KUeUNoD 8xHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="exHEW/Lv"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id s15-20020a508d0f000000b0044e946787a1si8471362eds.115.2022.09.23.17.09.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Sep 2022 17:09:50 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="exHEW/Lv"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 704F238582BA for ; Sat, 24 Sep 2022 00:09:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 704F238582BA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663978181; bh=bcgy6Gws4QQaFPKsf+rvcDemwRGgGW9doowNSVXQUhw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=exHEW/LvRizREKjlSdoLuIh6vl5KXNdlSik0ntYHRVh8+lDlZZfh7w4R5PpqGhrEV G8d+r74B5IUIub6Hkjc6kMTomyihQ0pW8Wgun1Y7OUJNwIgdmJ5Yqigp3Ul2/VS73j 4dPB+Q3eThL2nm2O40ML+IZ0xRqpU4wh0IIDC9Ew= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 9CEE33858C20 for ; Sat, 24 Sep 2022 00:07:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9CEE33858C20 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-662-fVcHp1KyOgSlpiTKgPZUyQ-1; Fri, 23 Sep 2022 20:07:54 -0400 X-MC-Unique: fVcHp1KyOgSlpiTKgPZUyQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 800E4185A78B; Sat, 24 Sep 2022 00:07:54 +0000 (UTC) Received: from localhost (unknown [10.33.36.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4793AC15BA5; Sat, 24 Sep 2022 00:07:54 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add test for type traits not having friend access Date: Sat, 24 Sep 2022 01:07:53 +0100 Message-Id: <20220924000753.1717363-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1744807594708540624?= X-GMAIL-MSGID: =?utf-8?q?1744807594708540624?= Tested powerpc64le-linux. Pushed to trunk. -- >8 -- 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. --- .../is_assignable/requirements/access.cc | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 libstdc++-v3/testsuite/20_util/is_assignable/requirements/access.cc 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 +}