From patchwork Tue Jan 16 21:28:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 188619 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp533879dye; Tue, 16 Jan 2024 13:29:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IErcsBl2rXsN+6AxBLroAo12ll7qqbxarkXAd9Fxd6dUwnY68DuxMhbYA6KU+bN6iyu7d14 X-Received: by 2002:a05:620a:80b:b0:783:26c0:5ae with SMTP id s11-20020a05620a080b00b0078326c005aemr8218978qks.47.1705440551939; Tue, 16 Jan 2024 13:29:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705440551; cv=pass; d=google.com; s=arc-20160816; b=aldPGewYjc00BA2/WlquLTchb2qBOPiVQYTZPtBOs9DpvE0EE037y+7IiT0wrd8anI exvCUTN27C6i9IE33jqATsf1z5cXNOI5X3UGZhssQ3xQhq9V+g+pXMHJyHR3qxnIkG7N lnwbCznTdZKzkj8rAaOR0bfM4zMOghn78iA5xNJa3nmQJ6gdLIUsnW5XHeiz9JrV0K9J kToRSiwPaqDQxTLjwIE5fS2V0PUWlOKD0OkWgUQ+XxyuDKebHknPr8O8JzxDVVhbs+Pw nyCjd/iCWu9tJCyjftDx68DGXjt9F8vHhZNjBkqb5l/fMMEZwuWtzgnl3vQbWfPrk8bw kO0g== 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=Ep4EZbIpiDlFQ8c+yw/BU8i+gHpL/xAljbtclBDMpyY=; fh=2BFo3VQCimnyWTJsWe6sNdepvNrW+J/2ctoM6N7MZ0Y=; b=Nj5D8IVOiHfZb1cJG/bN3Nhr/AROzj38pk5ucm1vaW5EsQLue8QY8SMAYtfumvGIoj LQi59Isbth5hyPMWqe9kZuos+NlEzi7S4u9ENQjOY3JtSxEF2BbYHFCPBEUbcnleXZyF nUBdXGoNmTAYh44WtIMhyQpOjeDC9Ft0G7Vk7kIU+Y5qZNWGzt351BkvtQs/ieoylEo/ h4xjJdRbUjgBYXRcEGlHsvcHJf9lJhy4Xx3+cdZlLBlALGET6Xl5H3PAJDTG1hjNSsuB CByvg/kB7q3UrZk9pP1vxRkxzSnokqEeDUzAYHK89jFe2MHInw3EOehPLTByy2PqWoKx VjNw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PP5ME9Ia; 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 y4-20020a37e304000000b0078334092c60si10546609qki.70.2024.01.16.13.29.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 13:29:11 -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=PP5ME9Ia; 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 9DC253857B92 for ; Tue, 16 Jan 2024 21:29:11 +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.129.124]) by sourceware.org (Postfix) with ESMTPS id 40A473857C43 for ; Tue, 16 Jan 2024 21:28:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 40A473857C43 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 40A473857C43 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705440511; cv=none; b=f7SSgSUw6c8J0Z/SKj0rMgmlflBxTDTAZMi/M6Eijh/Cx9kE9uOdmdC92q4ElSzZ4edv13HmAAvnM64S49+E+fCQhTf8NT3yaiORbNLB/ieps69Hyguzcgqqi29Xp/cwIYM6yYdCZp9tRifgE/yhumxk4MP/qZnZVWfn+arEGcc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705440511; c=relaxed/simple; bh=iT68oAY/RxupeVeNQFgajc4dVGz956hnj/iq+YXlBoQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=UQc9Luo0gmvOeNjFEjvvdoDizSzVkuroMLE/9K6+J2cLA7VrgiFuoTx1JT5p5A2tbWFp9V8Ts8kZ6heG57P609DE8zBf4p5QIQR9ypWAdtMO/i3FEs9JCFj8RMk1f+imtLOkNE0Xr+PoiMl4YRZWhqwAmv29R+TtTf8tskZNHb0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705440508; 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=Ep4EZbIpiDlFQ8c+yw/BU8i+gHpL/xAljbtclBDMpyY=; b=PP5ME9IaOtVVg79BW1A8DAGbMDOMaMuwrQEMQFxeeyeBhP7GyVMcMzWGp58AWzDo6/OG6f xwNf7zdiRATenF4uLmGkLwyAH15gC1PI81ItGCzSqAayxqBawqUrpQ7hFtk0RsvjLjhOy3 pea6BGze7FEh3GcCpV6goLmLu1wiubg= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-103-aJ6AS6plPhuWd36HHRG_ww-1; Tue, 16 Jan 2024 16:28:26 -0500 X-MC-Unique: aJ6AS6plPhuWd36HHRG_ww-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id AD18E2837803 for ; Tue, 16 Jan 2024 21:28:25 +0000 (UTC) Received: from pdp-11.lan (unknown [10.22.18.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D28B2026D6F; Tue, 16 Jan 2024 21:28:25 +0000 (UTC) From: Marek Polacek To: GCC Patches , Jason Merrill Subject: [PATCH] c++: fix ICE with xobj in destructor [PR113340] Date: Tue, 16 Jan 2024 16:28:13 -0500 Message-ID: <20240116212813.999293-1-polacek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 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_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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: 1788284032007347300 X-GMAIL-MSGID: 1788284032007347300 Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? -- >8 -- Here we crash in maybe_retrofit_in_chrg on an invalid dtor with explicit this. Such member functions do not get converted to METHOD_TYPE. If a dtor gets parameters, we reset arg_types to void_list_node in grokdeclarator. This results in m_r_in_c receiving: void (void) and crashing on parms = DECL_CHAIN (DECL_ARGUMENTS (fn)); This patch avoid the ICE by resetting is_xobj_member_function after emitting the error. Then m_r_in_c gets void S:: (struct S *) which does not cause a crash. PR c++/113340 gcc/cp/ChangeLog: * decl.cc (grokdeclarator) : Clear is_xobj_member_function in case of an error. gcc/testsuite/ChangeLog: * g++.dg/cpp23/explicit-obj-diagnostics9.C: New test. --- gcc/cp/decl.cc | 1 + gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics9.C | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics9.C base-commit: 6a6f338c1cbfc2585cd85358a83e601fb959445e diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index b10a72a87bf..2e5702971c4 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -13743,6 +13743,7 @@ grokdeclarator (const cp_declarator *declarator, "destructors may not have parameters"); arg_types = void_list_node; parms = NULL_TREE; + is_xobj_member_function = false; } type = build_function_type (type, arg_types); diff --git a/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics9.C b/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics9.C new file mode 100644 index 00000000000..d420793c1e1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics9.C @@ -0,0 +1,6 @@ +// PR c++/113340 +// { dg-do compile { target c++23 } } + +struct S { + ~S(this S &) = default; // { dg-error "destructors may not have parameters" } +};