From patchwork Thu Apr 14 21:09:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1617460 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=ZfgYtj6y; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KfXDW4xFkz9sBJ for ; Fri, 15 Apr 2022 07:10:34 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3AD0C3857353 for ; Thu, 14 Apr 2022 21:10:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3AD0C3857353 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1649970631; bh=KeLbSTWCZKaZx4BHJft+TNuGV+8Ds0dXUPkUTd9u6LA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ZfgYtj6y7EIvo6o/6B8tvOWbVavM9JwZRjsc1KP9p9az9iiHsNxU2A87qo2dhpG0z maPSOJ1EORiXfjIQAUgrXV6oc7GpC1e+T4JpqgkrO9aMsC65CRhguRTgbS+kn3U+Ww L/DEVUXokTVXqTXZHxl8VKDIcgW5g7EJ78/uddG4= 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 ED27F3858C53 for ; Thu, 14 Apr 2022 21:09:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ED27F3858C53 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-572-CBWzEBhpPVKtHUbZPiJTqg-1; Thu, 14 Apr 2022 17:09:47 -0400 X-MC-Unique: CBWzEBhpPVKtHUbZPiJTqg-1 Received: by mail-qk1-f199.google.com with SMTP id bj2-20020a05620a190200b005084968bb24so4142517qkb.23 for ; Thu, 14 Apr 2022 14:09:47 -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=KeLbSTWCZKaZx4BHJft+TNuGV+8Ds0dXUPkUTd9u6LA=; b=bx/KqsR9HX3KEapJyTskKaSlC1jqdOmDD5K3O8RhOXh0DJouBxsLfLds2vDxAMbuPG f5DmjiXk7lGDZfN1YvjumkHuqmhsrnukOlfr2rB6pACzLRRBz9Yx6Uys8JOL59V8yd/w lXt0KmZOqHd+MZwUOxWdtyl13P4rSCdrcSJztL3GxASgnH1vNNjlAn7EtKaWpI2FUrty 1ts79XLswmcIOm9AjBTj2FHFxiaySRaXlECvyqB1zk5Yi1xjv7LW1KElIFgWoGPsQdrP b12ZtBGXc6GNk2ivob6Yxu9xVcGpclfrrrLgfkH+6gVaFMBQGE0EVOGo6lcyDgDoE0i1 nuPw== X-Gm-Message-State: AOAM533X4SkunN3KX7flupwnKtEsXI/2zewoWRUMNcqhvK67Dj/5hCbW s3VM9CbiL4OYkhX+r3qqfIiVoplUu+Zfw4DGSQWAVWJVe74t35/MQjW1BK6fZeYYbhDiF11g8UI X0vpDPhep2D1AaRjDqo8zrKdhXqunOUHqX3+XnZDj4evnD4l8tpyp31LKjuLy4FvrpQ== X-Received: by 2002:a37:a897:0:b0:69c:329:2310 with SMTP id r145-20020a37a897000000b0069c03292310mr3402624qke.349.1649970586620; Thu, 14 Apr 2022 14:09:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOofnKBYVhk0CVlQP3gBMSVd6fSQ/iy3RkUr1gE1lDb2HHNj2q/rLqINPxAKJ7fSsNXhR/tg== X-Received: by 2002:a37:a897:0:b0:69c:329:2310 with SMTP id r145-20020a37a897000000b0069c03292310mr3402589qke.349.1649970586132; Thu, 14 Apr 2022 14:09:46 -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 i4-20020a05620a074400b0069c1a39e0c3sm1376354qki.88.2022.04.14.14.09.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 14:09:45 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: constexpr trivial -fno-elide-ctors [PR104646] Date: Thu, 14 Apr 2022 17:09:42 -0400 Message-Id: <20220414210942.3482919-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.1 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, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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" The constexpr constructor checking code got confused by the expansion of a trivial copy constructor; we don't need to do that checking for defaulted ctors, anyway. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/104646 gcc/cp/ChangeLog: * constexpr.cc (maybe_save_constexpr_fundef): Don't do extra checks for defaulted ctors. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/constexpr-fno-elide-ctors1.C: New test. --- gcc/cp/constexpr.cc | 3 +- .../g++.dg/cpp0x/constexpr-fno-elide-ctors1.C | 89 +++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-fno-elide-ctors1.C base-commit: 74b2e20222cf4fb24b90561ddb6f0989738bb722 diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index b170053e8e1..e89440e770f 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -920,7 +920,8 @@ maybe_save_constexpr_fundef (tree fun) if (!potential && complain) require_potential_rvalue_constant_expression (massaged); - if (DECL_CONSTRUCTOR_P (fun) && potential) + if (DECL_CONSTRUCTOR_P (fun) && potential + && !DECL_DEFAULTED_FN (fun)) { if (cx_check_missing_mem_inits (DECL_CONTEXT (fun), massaged, complain)) diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-fno-elide-ctors1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-fno-elide-ctors1.C new file mode 100644 index 00000000000..71c76fa0247 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-fno-elide-ctors1.C @@ -0,0 +1,89 @@ +// PR c++/104646 +// { dg-do compile { target c++11 } } +// { dg-additional-options -fno-elide-constructors } + +template struct pair { + _T1 first; + int second; +}; +template class __normal_iterator { + _Iterator __traits_type; + +public: + constexpr __normal_iterator() {} +}; +template class allocator; +template struct allocator_traits; +template struct allocator_traits> { + using value_type = _Tp; + template using rebind_alloc = allocator<_Up>; +}; +template struct __alloc_traits { + typedef allocator_traits<_Alloc> _Base_type; + typedef typename _Base_type::value_type &const_reference; + template struct rebind { + typedef typename _Base_type::template rebind_alloc<_Tp> other; + }; +}; +template struct _Vector_base { + typedef typename __alloc_traits<_Alloc>::template rebind<_Tp>::other _Tp_alloc_type; +}; +template > class vector { +public: + typename __alloc_traits< + typename _Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_reference + operator[](long); +}; +enum match_flag_type {}; +template class Trans_NS___cxx11_basic_regex; +class Trans_NS___cxx11_match_results; +enum _RegexExecutorPolicy { _S_auto }; +template +bool __regex_algo_impl(Trans_NS___cxx11_match_results &, + const Trans_NS___cxx11_basic_regex<_CharT, _TraitsT> &); +template class _Executor; +template +class Trans_NS___cxx11_basic_regex {}; +class Trans_NS___cxx11_match_results : vector { + template + friend bool __regex_algo_impl(Trans_NS___cxx11_match_results &, + const Trans_NS___cxx11_basic_regex<_Cp, _Rp> &); +}; +template +void regex_search(_Bi_iter, _Alloc, + Trans_NS___cxx11_basic_regex<_Ch_type, _Rx_traits>) { + __regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits, _S_auto, false>; +} +match_flag_type __regex_algo_impl___flags; +template +bool __regex_algo_impl( + Trans_NS___cxx11_match_results &__m, + const Trans_NS___cxx11_basic_regex<_CharT, _TraitsT> &__re) { + __normal_iterator __e, __s; + _Executor __executor(__s, __e, __m, __re, + __regex_algo_impl___flags); + __executor._M_match(); + return false; +} +template class _Executor { +public: + _Executor(__normal_iterator, __normal_iterator, + vector, Trans_NS___cxx11_basic_regex, match_flag_type); + void _M_match() { _M_dfs(); } + void _M_dfs(); + vector>> _M_rep_count; +}; +long _M_rep_once_more___i; +template +void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>::_M_dfs() { + auto __rep_count = _M_rep_count[_M_rep_once_more___i]; +} +char main___trans_tmp_1; +void main___trans_tmp_2() { + Trans_NS___cxx11_basic_regex re; + regex_search(main___trans_tmp_1, main___trans_tmp_2, re); +}