From patchwork Thu Jan 25 20:22:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 192293 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:e09d:b0:103:945f:af90 with SMTP id gm29csp233997dyb; Thu, 25 Jan 2024 12:23:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGrP3CROvt2TYgbPfJnPEAWIc6pvukDOCCUpTHKia+x9uFLtgBrm5idbnwbmqnBaAMw3y72 X-Received: by 2002:a05:6808:3a0d:b0:3bd:b5a9:d824 with SMTP id gr13-20020a0568083a0d00b003bdb5a9d824mr444814oib.62.1706214226574; Thu, 25 Jan 2024 12:23:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706214226; cv=pass; d=google.com; s=arc-20160816; b=ggFLEnUzAgDrSpMcSPUEm8MruZDXU55p+Grc7VWkBepq8NSZ4DKaDPODHVwO7RjEw3 4FMFFJLFPDF95RD6zQ62LS2gHYqpqy6U6AsiDFSROyar88qoLeJI3N8dr6sOTyyVoj0C wrX7Da/O8IKpJGXv3rv/yyUYsYb6APsWJnWtnYHLpi4asWXYbaqt+QvJATzjC3JxAT0x vjXQ0STkPhr2jklYEfCuvrKrLhRQJolwIWAPLasBifW39HWI05rNwJIcJV9P/2Q0owMt mGJhdSSQaCDvmyIQktbQYiotb+++Tm0Rj6v7B63r+HVNu7Ll7EPYUaxDEu+ZW4y/A4cv 7Nwg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=7PgKvbQAF1tgzLYHIKItA3SPg1Tz8tMOUiBmbCiyJMY=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=ny5EzlFRLFo/E5iJSr5R8f3FpVOKNuX6YayGodnUceWwSrI28E/VWPFwwYVDkcmrAQ ITArO1PC0BTBSpkElVa60fr6cYlx0ipqGDiNKj6inyY68icEdAg3Suuhk7n8TNbJoCYl nKni6bHv1ZN/x9+kKXcWiNTOlABlyOwSRB7elspxHwJQguYKwBm7V2tu0ECfwUfuskD9 //Q01cW1Ri87iZ/Vw7ZgowGZxmXP8Ra6ltqjXGM/9oti0v1S5Hz02bar5w6dpDiCSiv6 dZBa+qP8kupj8SbNktbv7P6ovaWKnETBO2fjBPFBywNfXS4tWGJ/FeSDXHbTQDYSsr9x SCQQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IfvuQHBP; arc=pass (i=1); 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=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id y13-20020a05622a004d00b0042a4ec9fc93si6809941qtw.7.2024.01.25.12.23.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 12:23:46 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=IfvuQHBP; arc=pass (i=1); 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=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B505C38582AF for ; Thu, 25 Jan 2024 20:23:45 +0000 (GMT) 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 D8D7F3858282 for ; Thu, 25 Jan 2024 20:22:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D8D7F3858282 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D8D7F3858282 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706214147; cv=none; b=KPuEt840oSchRtVMJ+PTqR6/ZY3sxPYqTjVxRkNcZW/P+Rnh2m149thFWMxBZfdlnN3lMnZRUqe5kvOIK5NnG4dwkSj6H9/WwrPhuNsRVvCfcOv7xSrjDuOBGGw/nznM/RzqynXS52eSkfnOtrDAnhx1Ug1H6QwrvuKHfWzDFQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706214147; c=relaxed/simple; bh=HrRy9FhssGJOufYbr5BuMhtDUWmKSr8QcBXYXrbTvY8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=NL38BgVeEOMLROw6yyLzaGP3bJyB7pMMME1Td9Y+Z2mRzg7lodcQK9j041hVsSPNmis/5d2+7LLYT3u5DeIhPslimYvf4SFA6QW8IOX16l+uIPo8TSUCjAblev7ywxyhrkhPPoE+DI/dQ4WoqTCAgxl9Uo+rNXCJaPwbH6POObA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706214142; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7PgKvbQAF1tgzLYHIKItA3SPg1Tz8tMOUiBmbCiyJMY=; b=IfvuQHBP1CmyNwqNukIvuewKE4slkvKdZj5G5O96da+ZYomizXCqDOmBMSBx1VL/L/X86Z qEGzGFLu+Rti0G1sC7YNu1ELOSL1mhOrIafHpCMh2bqNo5prr2MMPzy7dEPPgzv7dQ7D2e 0yrIN6To1t6WmyedkqLu6BC3PO9xngw= Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-616-DpR6BigfOGyI2ntmqa6zfA-1; Thu, 25 Jan 2024 15:22:20 -0500 X-MC-Unique: DpR6BigfOGyI2ntmqa6zfA-1 Received: by mail-oi1-f199.google.com with SMTP id 5614622812f47-3bd49a8f086so11481850b6e.0 for ; Thu, 25 Jan 2024 12:22:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706214140; x=1706818940; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7PgKvbQAF1tgzLYHIKItA3SPg1Tz8tMOUiBmbCiyJMY=; b=VLbuukQ/z3hhqJXHuPCu2c9xXEDvCI7YS/d0lm8DBAnMBRoB6jiu1WyXjGMqjHqCOe mxQsj0WwCoQ/BVRHqv+hY2j9UQfEjlix6zcbpqc2lCKwcuCF3QOEFd+1naHE6NAC0d9O pXiFI2lgWKiVbcuCylc7N7WanWoA2QVl4Rr915IROxu0260D4IWLCsGNvHf7jtt2LxhE 9e4TZFq/17J6iReW+Xl81V31E6vzB1BRr5I7BFCnbE6wHveidsUO6T7DlgDF07Tt410w ZL4/4NdZ0yZZasdzzmN5lDrz5wdaQc9NC22tq//qizFd2+YapxhmgjXNwvTFiBEkTIyY E2jQ== X-Gm-Message-State: AOJu0YzX3QiJXHkitm6uziO+vq4kcBPSVobfCVjRJon7jtJVDQuy4eug QEa/GQ4mDngglqKBPe+hPME6SCYyRfyU0iHyTxd0gOi9MuzVH6ch38Q1eh2N5fW5jK2cKe6mJDz 1Dt08YIAL3subjwFomWPijKGIlQI5QbOeGvdwQqrMfZapvcF0RIyit/pbHJwnX3TtD1zyJZvsAz pIqKY/3mqPonn7UPtXEjXnpv9io4zr3/xuB9w= X-Received: by 2002:a05:6808:2122:b0:3bd:e24d:7c42 with SMTP id r34-20020a056808212200b003bde24d7c42mr296494oiw.11.1706214139952; Thu, 25 Jan 2024 12:22:19 -0800 (PST) X-Received: by 2002:a05:6808:2122:b0:3bd:e24d:7c42 with SMTP id r34-20020a056808212200b003bde24d7c42mr296484oiw.11.1706214139550; Thu, 25 Jan 2024 12:22:19 -0800 (PST) Received: from jason.com (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id de29-20020a05620a371d00b007835c9bf30csm5348642qkb.83.2024.01.25.12.22.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 12:22:19 -0800 (PST) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: array of PMF [PR113598] Date: Thu, 25 Jan 2024 15:22:16 -0500 Message-Id: <20240125202216.1228203-1-jason@redhat.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 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_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_WEB, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789095289008539988 X-GMAIL-MSGID: 1789095289008539988 Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- Here AGGREGATE_TYPE_P includes pointers to member functions, which is not what we want. Instead we should use class||array, as elsewhere in the function. PR c++/113598 gcc/cp/ChangeLog: * init.cc (build_vec_init): Don't use {} for PMF. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/initlist-pmf2.C: New test. --- gcc/cp/init.cc | 4 +++- gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C base-commit: c6c2a1d79eb333a00124bf67820a7f405d0d8641 prerequisite-patch-id: 32204a3e8393a5c133fa74b57979c77cd7742149 diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc index adbdfc2dbfc..ac37330527e 100644 --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -4864,7 +4864,9 @@ build_vec_init (tree base, tree maxindex, tree init, But for non-classes, that's the same as value-initialization. */ if (empty_list) { - if (cxx_dialect >= cxx11 && AGGREGATE_TYPE_P (type)) + if (cxx_dialect >= cxx11 + && (CLASS_TYPE_P (type) + || TREE_CODE (type) == ARRAY_TYPE)) { init = build_constructor (init_list_type_node, NULL); } diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C b/gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C new file mode 100644 index 00000000000..0fac8333c75 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C @@ -0,0 +1,12 @@ +// PR c++/113598 +// { dg-additional-options -Wno-c++11-extensions } + +struct Cpu +{ + int op_nop(); +}; +typedef int(Cpu::*OpCode)(); +void f() +{ + new OpCode[256]{&Cpu::op_nop}; +}