From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 CB431385C6CF for ; Mon, 1 Jul 2024 22:09:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CB431385C6CF 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 CB431385C6CF 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=1719871749; cv=none; b=eVnY3pb/8F1Kgr2FdFgZg0OiWcR9KYAnoqF85WktTa5pDgxqbLmJljmB3D0mNGtVCapCJt7V6jEtQFd4uHv6psijPfmbUmqQkk9WMKOehdW1+IVE1CW2XxKlJi4BkZ6PnV/jM8I4EYniH1TBS2ssyUdontHPZM0VcZ9fjyuU9Fs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719871749; c=relaxed/simple; bh=scRXoThtrY552DSCnTrJ4HDwa0wcr6/FmGCoYFTLvMw=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=Z8OsTXZdFCflkH+57aFTkVm+dszL52BqQ6GmsOSr7qJH1MGxXbCgHv9/sou1NJc3vHvzREwg83ryTdW/j7N0FKpJcB25AGuFzT5twdhw9kKEnIHwODHx+MmKfRcXGmD/ytcCWiMOz56aVkfONn66cwXjanUhBlrWLt1lyI6Uln8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719871747; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YqjLdwgFeZlRIdaP31k+cHpoxSCKYLLTrnIBH3NIvBk=; b=h1Zwyrc+WDb8iZS2oxgkTijDzwGVCQLKY43t3C1dzBC2lNUvrwRfgTnBdGDCdLJV73uPt4 O3R3RLcNfMV48LaweIbR9u7HteuR7YjNrS8EqxO/nqiJk4UjLM2VOxWlP6bqjPmJLfF2qd pu/laevZyW5OByzfYRcA5b6EQU9njdk= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-qsDO7isSNTuOWv2A4NykVg-1; Mon, 01 Jul 2024 18:09:06 -0400 X-MC-Unique: qsDO7isSNTuOWv2A4NykVg-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6b50b0270d8so44739606d6.0 for ; Mon, 01 Jul 2024 15:09:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719871745; x=1720476545; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YqjLdwgFeZlRIdaP31k+cHpoxSCKYLLTrnIBH3NIvBk=; b=eEA7zSU+YZtl9tge2nqfoM0ECvYZhYGPd4xllbr2x4bw/X/GPBHJdoNzY/vNyMLlnp ksEeRPb/Ai9j+xPFKL9y4sZp0JzPxjyObYIOJfLdEYcf96nIZP9ZZ6Wke3im7uXsrHW/ dB2EBS0jG6KA9H4PhRJzsZTvZyiugcebehxH8Im4lEE2Jo/izcQqjjDzchbUH886gcg/ 1r1S5m8Hx9wQPxihC7kA6SBZCN5Y6bMPUtKw+NC406r0KD+qp9ihRL2vtbzjR4eLiJPQ NfJzEEK/4m6EblRfYvXZ4JUC6cfRT4txLd5I3FR78l+iGmtu7Twh85AW1UUTGThAZZ6o Tgbg== X-Gm-Message-State: AOJu0YycnsyfbcLkYDVUkV+fQe7/CP6HDlP85Hk0YRC+0g0Kakj/edo7 XAX1z2mIcEkWRxzGZcKqPodRZkzQzKCE5q+/P/dhdwMo/82djnoGDGXrQoKzUY656/PxYWiag16 Ike2zM717m1bjeu0O088SSlnW9rsutiP/MONXKjzH4gB/e/I/6uM6Lqw= X-Received: by 2002:a05:6214:1941:b0:6b5:3cf3:1aa6 with SMTP id 6a1803df08f44-6b5b7059d1fmr111911606d6.9.1719871745648; Mon, 01 Jul 2024 15:09:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQn41I7zK7tjH/tP1exa3NfYSaWxUrOa3ZIxceLLucOOQHdXP5rP4oxnM7nWnURW1Hl5l4Ag== X-Received: by 2002:a05:6214:1941:b0:6b5:3cf3:1aa6 with SMTP id 6a1803df08f44-6b5b7059d1fmr111911376d6.9.1719871745272; Mon, 01 Jul 2024 15:09:05 -0700 (PDT) Received: from [192.168.1.130] (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 6a1803df08f44-6b59e60c95esm37006366d6.109.2024.07.01.15.09.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Jul 2024 15:09:04 -0700 (PDT) Message-ID: Date: Mon, 1 Jul 2024 18:09:04 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] c++: ICE with computed gotos [PR115469] To: Marek Polacek Cc: GCC Patches References: <20240626220436.496205-1-polacek@redhat.com> From: Jason Merrill In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.3 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 7/1/24 5:09 PM, Marek Polacek wrote: > On Mon, Jul 01, 2024 at 02:44:56PM -0400, Jason Merrill wrote: >> On 6/26/24 6:04 PM, Marek Polacek wrote: >>> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? >>> >>> -- >8 -- >>> This is a low-prio crash on invalid code where we ICE on a VAR_DECL >>> with erroneous type. I thought I'd try to avoid putting such decls >>> into ->names and ->names_in_scope but that sounds riskier than the >>> following cleanup. >>> >>> PR c++/115469 >>> >>> gcc/cp/ChangeLog: >>> >>> * decl.cc (decl_with_nontrivial_dtor_p): New. >> >> This name doesn't suggest non-static variable to me. Maybe >> automatic_var_with...? > > Sounds good. > >> While we're at it, we should also avoid complaining about thread-local by >> checking decl_storage_duration == dk_auto, since [stmt.dcl]/2 is >> specifically about automatic. > > Done here. > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? > > -- >8 -- > This is a low-prio crash on invalid code where we ICE on a VAR_DECL > with erroneous type. I thought I'd try to avoid putting such decls > into ->names and ->names_in_scope but that sounds riskier than the > following cleanup. > > PR c++/115469 > > gcc/cp/ChangeLog: > > * decl.cc (automatic_var_with_nontrivial_dtor_p): New. > (poplevel_named_label_1): Use it. > (check_goto_1): Likewise. > > gcc/testsuite/ChangeLog: > > * g++.dg/ext/label17.C: New test. > --- > gcc/cp/decl.cc | 21 +++++++++++++++++---- > gcc/testsuite/g++.dg/ext/label17.C | 18 ++++++++++++++++++ > 2 files changed, 35 insertions(+), 4 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/ext/label17.C > > diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc > index 03deb1493a4..d439b04bfa7 100644 > --- a/gcc/cp/decl.cc > +++ b/gcc/cp/decl.cc > @@ -514,6 +514,21 @@ level_for_consteval_if (cp_binding_level *b) > && IF_STMT_CONSTEVAL_P (b->this_entity)); > } > > +/* True if T is a non-static VAR_DECL that has a non-trivial destructor. > + See [stmt.dcl]/2. */ > + > +static bool > +automatic_var_with_nontrivial_dtor_p (const_tree t) > +{ > + if (error_operand_p (t)) > + return false; > + > + return (VAR_P (t) > + && !TREE_STATIC (t) Checking TREE_STATIC is redundant with checking decl_storage_duration. OK without the above line. > + && decl_storage_duration (CONST_CAST_TREE (t)) == dk_auto > + && TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (t))); > +} > + > /* Update data for defined and undefined labels when leaving a scope. */ > > int > @@ -575,8 +590,7 @@ poplevel_named_label_1 (named_label_entry **slot, cp_binding_level *bl) > if (bl->kind == sk_catch) > vec_safe_push (cg, get_identifier ("catch")); > for (tree d = use->names_in_scope; d; d = DECL_CHAIN (d)) > - if (TREE_CODE (d) == VAR_DECL && !TREE_STATIC (d) > - && TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (d))) > + if (automatic_var_with_nontrivial_dtor_p (d)) > vec_safe_push (cg, d); > } > > @@ -4003,8 +4017,7 @@ check_goto_1 (named_label_entry *ent, bool computed) > tree end = b == level ? names : NULL_TREE; > for (tree d = b->names; d != end; d = DECL_CHAIN (d)) > { > - if (TREE_CODE (d) == VAR_DECL && !TREE_STATIC (d) > - && TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (d))) > + if (automatic_var_with_nontrivial_dtor_p (d)) > { > if (!identified) > { > diff --git a/gcc/testsuite/g++.dg/ext/label17.C b/gcc/testsuite/g++.dg/ext/label17.C > new file mode 100644 > index 00000000000..076ef1f798e > --- /dev/null > +++ b/gcc/testsuite/g++.dg/ext/label17.C > @@ -0,0 +1,18 @@ > +// PR c++/115469 > +// { dg-do compile { target indirect_jumps } } > +// { dg-options "" } > + > +void > +fn1 () > +{ > + b = &&c; // { dg-error "not declared|not defined" } > + goto *0; > +} > + > +void > +fn2 () > +{ > +c: > + b = &&c; // { dg-error "not declared" } > + goto *0; > +} > > base-commit: c847dcf94499da62e5a28921b404e6e561645d99