From patchwork Sun Nov 5 17:42:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 161741 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2237368vqu; Sun, 5 Nov 2023 09:43:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IEJPFgpforK858Liv9cstLIPe13jefapV4HJ8AqpW591x6hmAmhHKbngWBUskIfen7WzLVa X-Received: by 2002:a1f:2996:0:b0:4ab:f516:98c3 with SMTP id p144-20020a1f2996000000b004abf51698c3mr3589070vkp.16.1699206183331; Sun, 05 Nov 2023 09:43:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699206183; cv=pass; d=google.com; s=arc-20160816; b=Qf/KqzI/M5brb37i7feVn+E8H63L+nx3LnnBkFm5YJSmTXmcFE9+Gq6F96GY+7hkkb W+Ie5mBdAqVK7lJvnVhaFv+8jSDhOB5v4OVPJCYDJzIu6tKK+uM3csRU/cAFqqarp7JS vTBfJCiLWzKiLwTFWDlKLZkmbfBc2N9iH9/b9syWABcC5gMrnBkzB5IvhVhy+nGa7/v3 ket1vdh6SDI/ZMgy5enh4h3eKy1G7oXVUDzk9S0RfjDm4JNln4awD5+4CvPHD29jSx/9 KGA64y+nT16p/UEi8m2awSgzB5blP050xo9VFIZrjz6rh00Kuu0dPkrCkpenVhxKi+dO u9rw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=Jy38YCyY/KqTmxMOP0DVB2DUQw9Ey2JRg3cLSR+uw5M=; fh=0xZT+NBKSeH8qOu04/61f1ZGePpF4jF/gxp331YE14k=; b=epiZgaHG3zwiUaweHZS18qMDJETvGihvkVlntkZ2ME3PuQeMe/Up3+1PuxbV5xF+Xd Sj3s16XpVbP8H/+D3ZTWb6SwSewhtS+DR254DvA64d5R67saHd/77mg/c+Vfd0zS6v+i Ds5j+NaNNgWo65O8xtMlP4k16m8GivsjY1V2j9tXAPF1ab1nw33nx72PatZvM7INaKey ZnGu19qrr9NfWAyhuii7n3l8rGuK1Sktxqx82TBW9U5H04QaiM+56k2E681T5PaZ+bzO txgCCDBaZ0h60Xcvq8ycUnovirMKHtAb+t3rX061drYgBcojbrMXsM+FRVHWPR7Dw64a GwKw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GaQjocAn; 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 h13-20020ac85e0d000000b004197196b0f0si4465429qtx.617.2023.11.05.09.43.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 09:43:03 -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=GaQjocAn; 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 1B5103858C41 for ; Sun, 5 Nov 2023 17:43:03 +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 6CE483858CDB for ; Sun, 5 Nov 2023 17:42:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6CE483858CDB 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 6CE483858CDB 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=1699206157; cv=none; b=FuVecrlD6S2HPIPSLBn9ZwES15TNLGOnWi4KBNN1OZ8U+MAy7cXnmPX42+6/4NI91mxtVLJGJ6C3HUhdjHbKNSo6lm3DgChx+ag+2Mi9GLvy6bVpOOJ+bYw9wE4/kK3i54aTRJ7jWxaKm0LDks66r7fcw4JlRMwGFwfMzSMyCvk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699206157; c=relaxed/simple; bh=6nLTalvIqfat/EvMsS1abxps0p+zjwZRJFQk4dJuUpk=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=MtDh/9ppuZwASroBFooRHMggokWfaqoZdTUbSWs1YvQjz41Hn8BszQr/42+jywBRhurzh7JINnfolScpA3IaLAM0alLiFrFTF5IY5VSvdK4I0t/0Vkh5kRMZyME0DbWKusplQDHApFMyf3HrsOnGRsttJqsWZk4Brm4ySdbMrNo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699206156; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=Jy38YCyY/KqTmxMOP0DVB2DUQw9Ey2JRg3cLSR+uw5M=; b=GaQjocAnHUZC0ny+cw8C3fiU7CU7W5HXPVvx5YfI/2XfLXnhxxfi5JuORUOU8z1iXL+8nu T/skIYmDgWV2RKk0i2TfO9Kl1ZQ51x9dWiZ3DDEHtuwOda5TH870cuYaXoKNPDeR75q1OE WUvYWSNV/7paFbE7mgOvb36m6Oy1XVE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-501--nxrp2-RNRueFvpHxMUMkA-1; Sun, 05 Nov 2023 12:42:34 -0500 X-MC-Unique: -nxrp2-RNRueFvpHxMUMkA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 437E6811E7E for ; Sun, 5 Nov 2023 17:42:34 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.81]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 05DE7492BE0; Sun, 5 Nov 2023 17:42:33 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 3A5HgVMw1794262 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sun, 5 Nov 2023 18:42:32 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3A5HgVSm1794261; Sun, 5 Nov 2023 18:42:31 +0100 Date: Sun, 5 Nov 2023 18:42:31 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: Fix error recovery ICE [PR112365] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK autolearn=no 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: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781746822759406134 X-GMAIL-MSGID: 1781746822759406134 Hi! check_field_decls for DECL_C_BIT_FIELD FIELD_DECLs with error_mark_node TREE_TYPE continues early and doesn't call check_bitfield_decl which would either set DECL_BIT_FIELD, or clear DECL_C_BIT_FIELD. So, the following testcase ICEs after emitting tons of errors, because SET_DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD asserts DECL_BIT_FIELD. The patch skips that for FIELD_DECLs with error_mark_node, another option would be to check DECL_BIT_FIELD in addition to DECL_C_BIT_FIELD. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-11-05 Jakub Jelinek PR c++/112365 * class.cc (layout_class_type): Don't SET_DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD on FIELD_DECLs with error_mark_node type. * g++.dg/cpp0x/pr112365.C: New test. Jakub --- gcc/cp/class.cc.jj 2023-11-04 09:02:35.380001476 +0100 +++ gcc/cp/class.cc 2023-11-04 10:03:34.974075429 +0100 @@ -6962,7 +6962,8 @@ layout_class_type (tree t, tree *virtual check_bitfield_decl eventually sets DECL_SIZE (field) to that width. */ && (DECL_SIZE (field) == NULL_TREE - || integer_zerop (DECL_SIZE (field)))) + || integer_zerop (DECL_SIZE (field))) + && TREE_TYPE (field) != error_mark_node) SET_DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD (field, 1); check_non_pod_aggregate (field); } --- gcc/testsuite/g++.dg/cpp0x/pr112365.C.jj 2023-11-04 10:05:58.285013791 +0100 +++ gcc/testsuite/g++.dg/cpp0x/pr112365.C 2023-11-04 10:05:14.879638217 +0100 @@ -0,0 +1,8 @@ +// PR c++/112365 +// { dg-do compile { target c++11 } } +// { dg-excess-errors "" } + +template struct A; +template A foo (T; +template struct A { constexpr A : T {} } +struct { bar ( { foo (this)