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 C39013831CB0 for ; Mon, 6 Jun 2022 18:39:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C39013831CB0 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-673-jh6Ss7L7OE6TBPXB2DJMcg-1; Mon, 06 Jun 2022 14:39:38 -0400 X-MC-Unique: jh6Ss7L7OE6TBPXB2DJMcg-1 Received: by mail-qv1-f70.google.com with SMTP id j2-20020a0cfd42000000b0045ad9cba5deso9318490qvs.5 for ; Mon, 06 Jun 2022 11:39:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=FRH1CT/yD4+5pY24Oo+9f2Ju3HrZcGWI/h/6tm3WmdE=; b=hJ86zUAvpEdrgyTD1D137qzKPQIbggFHl7yg/UkhOfw7uDb8ASMn8o0T0GYbgKzU1X opaw38v/M4QI7eT/CRGaLG/l2LgtgJJibx/kSFLwno7qPFD1C8XSPcEf670GoYmP/iP3 5Td3cdNDMUbbBLFl4xrCrsq2s2mAiAlIUcWx8A0cXFs0DRxJOBfqKcv4i/k8ylRQBPIW H9uz+Q09DzkdkIL1JiqxGQhERFdDXZCRUFVTMIvXsK7YiDK2m0z2HRJVKyKGpypgn0hM TS0vLvbCvNK26hUN99A7jJlH93nUUKQxzffINeO0REDHyHygLc3UU7X3w6qqRsM4EFiC RcYQ== X-Gm-Message-State: AOAM530cIhNJ5+Vos9DrkfJ8KX0zvX4Xx882W9V/2xsbVOgF+5K2GvKv fm6ihDDvWOdMDrHzwmE+IwtuWmuGhkk50oC25tHPNz6jPOkmQEzKCXP9nyIVTd+ReqlC0cYAKep 6M/SjnRjZJvjAvB4Azw== X-Received: by 2002:ac8:584b:0:b0:304:f08b:5dd4 with SMTP id h11-20020ac8584b000000b00304f08b5dd4mr3124410qth.77.1654540777404; Mon, 06 Jun 2022 11:39:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/exBTHm0j29qkERRvqBQUwMFKQnZ3k9GNLDPrl1IAt2aYMax+oG7OCybpn2PjpRJX8DqvSg== X-Received: by 2002:ac8:584b:0:b0:304:f08b:5dd4 with SMTP id h11-20020ac8584b000000b00304f08b5dd4mr3124387qth.77.1654540777049; Mon, 06 Jun 2022 11:39:37 -0700 (PDT) Received: from [192.168.1.100] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id j9-20020ac86649000000b00304ea3d2f62sm3601876qtp.41.2022.06.06.11.39.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Jun 2022 11:39:36 -0700 (PDT) Message-ID: <7b078b49-9a84-e357-87c3-be6609d10814@redhat.com> Date: Mon, 6 Jun 2022 14:39:35 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [C++ PATCH take #2] PR c++/96442: Improved error recovery in enumerations. To: Roger Sayle , gcc-patches@gcc.gnu.org References: <003c01d878c4$58219a70$0864cf50$@nextmovesoftware.com> From: Jason Merrill In-Reply-To: <003c01d878c4$58219a70$0864cf50$@nextmovesoftware.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=-8.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jun 2022 18:39:41 -0000 On 6/5/22 06:09, Roger Sayle wrote: > > Hi Jason, > My apologies for the long delay, but I've finally got around to > implementing your suggested improvements (implied by your review): > https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591504.html > of my patch for PR c++/96442: > https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590716.html > > The "How does that happen?" is insightful and leads to a cleaner > solution, setting ENUM_UNDERLYING_TYPE to integer_type_node when > issuing an error, so that this invariant holds during the parser's > error recovery. I've also moved the new testcase to the g++.dg/parse > subdirectory as per your feedback on my previous ICE-on-invalid fixes. > > This patch has been tested on x86_64-pc-linunx-gnu with make bootstrap > and make -k check with no new (unexpected) failures. Ok for mainline? OK. > 2022-06-05 Roger Sayle > > gcc/cp/ChangeLog > PR c++/96442 > * decl.cc (start_enum): When emitting a "must be integral" error, > set ENUM_UNDERLYING_TYPE to integer_type_node, to avoid an ICE > downstream in build_enumeration. > > gcc/testsuite/ChangeLog > PR c++/96442 > * g++.dg/parse/pr96442.C: New test cae. > > Thanks again, > Roger > -- > >> -----Original Message----- >> From: Jason Merrill >> Sent: 10 March 2022 05:06 >> To: Roger Sayle ; gcc-patches@gcc.gnu.org >> Subject: Re: [C++ PATCH] PR c++/96442: Another improved error recovery in >> enumerations. >> >> On 2/22/22 08:02, Roger Sayle wrote: >>> >>> This patch resolves PR c++/96442, another ICE-after-error regression. >>> In this case, invalid code attempts to use a non-integral type as the >>> underlying type for an enumeration (a record_type in the example given >>> in the bugzilla PR), for which the parser emits an error message but >>> allows the inappropriate type to leak to downstream code. >> >> How does that happen? >> >> Would it help to change dependent_type_p in start_enum to >> WILDCARD_TYPE_P? >> >>> The minimal >>> safe fix is to double check that the enumeration's underlying type >>> EUTYPE satisfies INTEGRAL_TYPE_P before calling int_fits_type_p in >>> build_enumerator. This is a one line fix, but correcting indentation >>> and storing a common subexpression in a variable makes the change look >>> a little bigger. >>> >>> This patch has been tested on x86_64-pc-linunx-gnu with make bootstrap >>> and make -k check with no new (unexpected) failures. Ok for mainline? >>> >>> >>> 2022-02-22 Roger Sayle >>> >>> gcc/cp/ChangeLog >>> PR c++/96442 >>> * decl.cc (build_enumeration): Check ENUM_UNDERLYING_TYPE is >>> INTEGRAL_TYPE_P before calling int_fits_type_p. >>> >>> gcc/testsuite/ChangeLog >>> PR c++/96442 >>> * g++.dg/pr96442.C: New test cae. >>> >>> >>> Thanks in advance, >>> Roger >>> -- >>> >