From patchwork Fri Apr 29 03:02:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1623950 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=os76TfA+; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KqHPC3btFz9sFr for ; Fri, 29 Apr 2022 13:03:27 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9E1573857433 for ; Fri, 29 Apr 2022 03:03:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9E1573857433 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1651201405; bh=DJ/Zt9CyyNzT/0WZRwa/sV2bD2eXx4do7OmSx1jDyYM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=os76TfA+5RQsf0mzAT/GvAQHV1FVNl3Boi9vtMsMSSvaBIPEfBuyYUoL1lle+5bqr ghZEPwJRmezRIcCZ05hXNI0BLIrkSd2zu6kNHeXS3Fq+hpJsftx1pKjAl9BUcs5UrD YgXOY9XXbru+PSqSuSui8r+v2WBi7Nr+wjLOqVdQ= 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 E5AB03857430 for ; Fri, 29 Apr 2022 03:02:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E5AB03857430 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-456-YBd7q3ZXPJWmtQgcn3rHwg-1; Thu, 28 Apr 2022 23:02:40 -0400 X-MC-Unique: YBd7q3ZXPJWmtQgcn3rHwg-1 Received: by mail-qv1-f69.google.com with SMTP id eo13-20020ad4594d000000b004466661ece9so5133865qvb.1 for ; Thu, 28 Apr 2022 20:02:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=DJ/Zt9CyyNzT/0WZRwa/sV2bD2eXx4do7OmSx1jDyYM=; b=xxDnrvWBAD2NLtI/InbeFt74F8KXKNf9leV6d7gBmSJjfaJzrw8sSG3AfrpafZ5iQj 3tEIqLJ0L7yCDe2PSVqzC1e6wptFW+OTQQXtMwbTyLQdjhuJWctO0iKfcuvlJmjfmGfB pHdvioswaV5edPKWjCwdrQZB6CAXMMTNWcOK/GQxm3ynKyT07URiM4E88rOgeLoNKKfm sGnOzzYWwdHNTH0du/ML+AjSqMYPmEWik0jfqQMNWRWnhMOFVukwH2C0GZkhF6odxT7Q QQXrOutgnOQRUisijWxB0rtxZqamysYkmA5bXTSHMCD9UiNZ8jCzm2iWevNu/Jj6/p1E WQ9w== X-Gm-Message-State: AOAM533/3gY5p8WRQfib4gjSUx6PZsSt9uiuEUu4dd7ighNvE35WFEj9 /Sgd/JvgCIJX39cjIcNfeeJPsPHcAmElJ2tx9poZW9VkT82WbtiNdSf9p7DlgzgwuQaYawKubxP abWXSjaTB1kQTtccZiOf/vQnq6vUiwV22y4jnp7U4IgUslFD1Rkd1y4n+z5Rkw8/Lng== X-Received: by 2002:a05:620a:b92:b0:67e:b7a2:dabd with SMTP id k18-20020a05620a0b9200b0067eb7a2dabdmr21455437qkh.106.1651201359384; Thu, 28 Apr 2022 20:02:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyy/wu2F6HHs2fPWvmedeNC/9DoEyL1moW+5AT3Q+eOCrC9VJ7FelUwlpDdy2/0qFWCHECzaw== X-Received: by 2002:a05:620a:b92:b0:67e:b7a2:dabd with SMTP id k18-20020a05620a0b9200b0067eb7a2dabdmr21455425qkh.106.1651201358914; Thu, 28 Apr 2022 20:02:38 -0700 (PDT) Received: from barrymore.redhat.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id b11-20020a05622a020b00b002f38fe59f03sm983313qtx.18.2022.04.28.20.02.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Apr 2022 20:02:38 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: traits, array of unknown bound of incomplete Date: Thu, 28 Apr 2022 23:02:36 -0400 Message-Id: <20220429030236.1098321-1-jason@redhat.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.4 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" My r161129 changed check_trait_type to reject arrays of unknown bound of incomplete type, but I can't find a rationale for that, and now think it's wrong: the standard just requires that the type be "complete, cv void, or an array of unknown bound." I imagine that allowing arrays of unknown bound is because an array of unknown bound can't change from incomplete to complete later in the translation unit, so there's no caching problem. Tested x86_64-pc-linux-gnu, applying to trunk. gcc/cp/ChangeLog: * semantics.cc (check_trait_type): Don't check completeness of element type of array of unknown bound. gcc/testsuite/ChangeLog: * g++.dg/ext/unary_trait_incomplete.C: Adjust. --- gcc/cp/semantics.cc | 3 +-- .../g++.dg/ext/unary_trait_incomplete.C | 24 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) base-commit: 97b30a399ef561f6f37a2c08c830fdf3141bb504 diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 9567559c962..377f61113c0 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -11978,8 +11978,7 @@ check_trait_type (tree type) return (check_trait_type (TREE_VALUE (type)) && check_trait_type (TREE_CHAIN (type))); - if (TREE_CODE (type) == ARRAY_TYPE && !TYPE_DOMAIN (type) - && COMPLETE_TYPE_P (TREE_TYPE (type))) + if (TREE_CODE (type) == ARRAY_TYPE && !TYPE_DOMAIN (type)) return true; if (VOID_TYPE_P (type)) diff --git a/gcc/testsuite/g++.dg/ext/unary_trait_incomplete.C b/gcc/testsuite/g++.dg/ext/unary_trait_incomplete.C index b60ce84dcb2..6c83279c030 100644 --- a/gcc/testsuite/g++.dg/ext/unary_trait_incomplete.C +++ b/gcc/testsuite/g++.dg/ext/unary_trait_incomplete.C @@ -5,72 +5,72 @@ struct C { }; bool nas1 = __has_nothrow_assign(I); // { dg-error "incomplete type" } bool nas2 = __has_nothrow_assign(C[]); -bool nas3 = __has_nothrow_assign(I[]); // { dg-error "incomplete type" } +bool nas3 = __has_nothrow_assign(I[]); bool nas4 = __has_nothrow_assign(void); bool nas5 = __has_nothrow_assign(const void); bool tas1 = __has_trivial_assign(I); // { dg-error "incomplete type" } bool tas2 = __has_trivial_assign(C[]); -bool tas3 = __has_trivial_assign(I[]); // { dg-error "incomplete type" } +bool tas3 = __has_trivial_assign(I[]); bool tas4 = __has_trivial_assign(void); bool tas5 = __has_trivial_assign(const void); bool nco1 = __has_nothrow_constructor(I); // { dg-error "incomplete type" } bool nco2 = __has_nothrow_constructor(C[]); -bool nco3 = __has_nothrow_constructor(I[]); // { dg-error "incomplete type" } +bool nco3 = __has_nothrow_constructor(I[]); bool nco4 = __has_nothrow_constructor(void); bool nco5 = __has_nothrow_constructor(const void); bool tco1 = __has_trivial_constructor(I); // { dg-error "incomplete type" } bool tco2 = __has_trivial_constructor(C[]); -bool tco3 = __has_trivial_constructor(I[]); // { dg-error "incomplete type" } +bool tco3 = __has_trivial_constructor(I[]); bool tco4 = __has_trivial_constructor(void); bool tco5 = __has_trivial_constructor(const void); bool ncp1 = __has_nothrow_copy(I); // { dg-error "incomplete type" } bool ncp2 = __has_nothrow_copy(C[]); -bool ncp3 = __has_nothrow_copy(I[]); // { dg-error "incomplete type" } +bool ncp3 = __has_nothrow_copy(I[]); bool ncp4 = __has_nothrow_copy(void); bool ncp5 = __has_nothrow_copy(const void); bool tcp1 = __has_trivial_copy(I); // { dg-error "incomplete type" } bool tcp2 = __has_trivial_copy(C[]); -bool tcp3 = __has_trivial_copy(I[]); // { dg-error "incomplete type" } +bool tcp3 = __has_trivial_copy(I[]); bool tcp4 = __has_trivial_copy(void); bool tcp5 = __has_trivial_copy(const void); bool vde1 = __has_virtual_destructor(I); // { dg-error "incomplete type" } bool vde2 = __has_virtual_destructor(C[]); -bool vde3 = __has_virtual_destructor(I[]); // { dg-error "incomplete type" } +bool vde3 = __has_virtual_destructor(I[]); bool vde4 = __has_virtual_destructor(void); bool vde5 = __has_virtual_destructor(const void); bool tde1 = __has_trivial_destructor(I); // { dg-error "incomplete type" } bool tde2 = __has_trivial_destructor(C[]); -bool tde3 = __has_trivial_destructor(I[]); // { dg-error "incomplete type" } +bool tde3 = __has_trivial_destructor(I[]); bool tde4 = __has_trivial_destructor(void); bool tde5 = __has_trivial_destructor(const void); bool abs1 = __is_abstract(I); // { dg-error "incomplete type" } bool abs2 = __is_abstract(C[]); -bool abs3 = __is_abstract(I[]); // { dg-error "incomplete type" } +bool abs3 = __is_abstract(I[]); bool abs4 = __is_abstract(void); bool abs5 = __is_abstract(const void); bool pod1 = __is_pod(I); // { dg-error "incomplete type" } bool pod2 = __is_pod(C[]); -bool pod3 = __is_pod(I[]); // { dg-error "incomplete type" } +bool pod3 = __is_pod(I[]); bool pod4 = __is_pod(void); bool pod5 = __is_pod(const void); bool emp1 = __is_empty(I); // { dg-error "incomplete type" } bool emp2 = __is_empty(C[]); -bool emp3 = __is_empty(I[]); // { dg-error "incomplete type" } +bool emp3 = __is_empty(I[]); bool emp4 = __is_empty(void); bool emp5 = __is_empty(const void); bool pol1 = __is_polymorphic(I); // { dg-error "incomplete type" } bool pol2 = __is_polymorphic(C[]); -bool pol3 = __is_polymorphic(I[]); // { dg-error "incomplete type" } +bool pol3 = __is_polymorphic(I[]); bool pol4 = __is_polymorphic(void); bool pol5 = __is_polymorphic(const void);