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.133.124]) by sourceware.org (Postfix) with ESMTPS id 16ED938114E8 for ; Mon, 1 Jul 2024 18:45:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 16ED938114E8 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 16ED938114E8 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=1719859502; cv=none; b=Hx7RZ9eQAd1ZD8DPhVmmyUAb/yT02C/PG8Kx52W8Nsbp0T0vUiY+PbNVKEifuZTi4Mav9Qw2wE1A3nliFCfH7J9vAfkaqvgTc5l4a2C4NU0Igj/AZoo6ovrYk7A3Q21ZvSb3/IBIc5dXa08Hf11JFhk7DtsNTtT43FkPpU5F72w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719859502; c=relaxed/simple; bh=OthPq5bVgB3TzOj27wR8U2aX41AG3L5ne0Gg2BonuGI=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=pKua1EKNZZDMf9+q7WRqjTB+bMKhuVm9QVCaqk6sASrui8468ZkQqoZEA6yd18S2ewOBr8PupiAdXgYqGxTWbKuOwtiJlnL0KYHe09IN6UqVT4yrfwBxg+5IQyCpmxB+KYvJ4IoOoJfF4+yIFz45XrKZQUOZSS8ObnOzptnfSnI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719859500; 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: in-reply-to:in-reply-to:references:references; bh=9qHjuGIydSSvZSsUqwpNA1pnBslgm8uG6iIu0xl2Sl0=; b=jCwP4+gp9i4NqULFuguSpRkprqtLf7rFL/m52HrraMNKRuG/CXrxXefymFxs2Z8R46fC4y ILs5piOzWssdI420X55sIjoeslorJRkKppnglbuHbMQSOGrwLVA4sAvH2CzWoHraVS/61M OgThWuGzG1cQyLQnCzJqDD3u5BkYnm4= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-692-LxBg60ExOkieoBmXTOQs5A-1; Mon, 01 Jul 2024 14:44:58 -0400 X-MC-Unique: LxBg60ExOkieoBmXTOQs5A-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6b057a9690bso40097556d6.2 for ; Mon, 01 Jul 2024 11:44:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719859498; x=1720464298; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9qHjuGIydSSvZSsUqwpNA1pnBslgm8uG6iIu0xl2Sl0=; b=JCl6NtSkazCTTjOjttauqsHLVJJZ3RG9R2FU0q5Qdws2xyQeqdE2GtSEfedABf49UE g/HwgzabCzB1vHi0+7Xii8QwDdHF/JIs/vbbZjs9CqgxDesMLAtHHPQy9+DwNpG3VKJr dsAm4iSw7wNJIkvYxCMQ1qfXfc1EIDmx/s651kMYCmzWiedk72rqQ1e36MEWshIEVvyG m11aBzhqX8xiLGHIcLMLpjgoC8Br/m3ePJ8iBSat3JRdrZDabe6QLfWvSyIuMEa46HaI l/NMbLeBzivGlq3xWps/+H48H44KnDcpzaLyaLQ5V1YkBREr30Lmps9Y82L+h0mk5Dfi 1eyw== X-Forwarded-Encrypted: i=1; AJvYcCXhPFVrtYLEDlev4BqIbPV8l8iy8td8J+nKSgVyWDvOE5M+Tr0vp+UL45RuvujeOjCAhhZEs0A1X0I1GBeGXrwKWnGu+md0yQ== X-Gm-Message-State: AOJu0YyJo4f6NS8YEYnMsg/o0E/V01NASmLX1W57XpcpIhLjd904OWx5 op0GoACy+2OSMQ9sXaUG+QV/l4LdQjAphNFQ+qx3DJXEHpm6QbUT9OvQVZDLIojukFCZOVq390O ZV4c+PvKXx2JKLdMobL/jNosSvQcCBTmRXAph5WbV3sYnJmNpCnVHORWIMsxmgSE= X-Received: by 2002:a05:6214:ca3:b0:6b5:71c4:b8dd with SMTP id 6a1803df08f44-6b5b7098c91mr81205266d6.14.1719859497741; Mon, 01 Jul 2024 11:44:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEjKWDZahwZBoFR/DH3joXn5blltWarKYU1pSAfqY4FmJgYJQTN1fSCEEHOLRJv9GyQIl6vCw== X-Received: by 2002:a05:6214:ca3:b0:6b5:71c4:b8dd with SMTP id 6a1803df08f44-6b5b7098c91mr81205136d6.14.1719859497394; Mon, 01 Jul 2024 11:44:57 -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-6b59e563251sm36032486d6.31.2024.07.01.11.44.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Jul 2024 11:44:56 -0700 (PDT) Message-ID: Date: Mon, 1 Jul 2024 14:44:56 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] c++: ICE with computed gotos [PR115469] To: Marek Polacek , GCC Patches References: <20240626220436.496205-1-polacek@redhat.com> From: Jason Merrill In-Reply-To: <20240626220436.496205-1-polacek@redhat.com> 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 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...? 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. > (poplevel_named_label_1): Use it. > (check_goto_1): Likewise. > > gcc/testsuite/ChangeLog: > > * g++.dg/ext/label17.C: New test. > --- > gcc/cp/decl.cc | 19 +++++++++++++++---- > gcc/testsuite/g++.dg/ext/label17.C | 18 ++++++++++++++++++ > 2 files changed, 33 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..e5696079c28 100644 > --- a/gcc/cp/decl.cc > +++ b/gcc/cp/decl.cc > @@ -514,6 +514,19 @@ 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. */ > + > +static bool > +decl_with_nontrivial_dtor_p (const_tree t) > +{ > + if (error_operand_p (t)) > + return false; > + > + return (VAR_P (t) > + && !TREE_STATIC (t) > + && TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (t))); > +} > + > /* Update data for defined and undefined labels when leaving a scope. */ > > int > @@ -575,8 +588,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 (decl_with_nontrivial_dtor_p (d)) > vec_safe_push (cg, d); > } > > @@ -4003,8 +4015,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 (decl_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: 0731985920cdeeeb028f03ddb8a7f035565c1594