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 869E73858413 for ; Wed, 25 May 2022 12:28:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 869E73858413 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-570-Hho6UrCBOCaelf3TIKxZXQ-1; Wed, 25 May 2022 08:28:46 -0400 X-MC-Unique: Hho6UrCBOCaelf3TIKxZXQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 34D9D1C01B35; Wed, 25 May 2022 12:28:46 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.106]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DA675400F3E6; Wed, 25 May 2022 12:28:45 +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 24PCSgiQ039535 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 25 May 2022 14:28:43 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 24PCSgZ1039534; Wed, 25 May 2022 14:28:42 +0200 Date: Wed, 25 May 2022 14:28:42 +0200 From: Jakub Jelinek To: David Malcolm Cc: "Joseph S. Myers" , Marek Polacek , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] c: Improve build_component_ref diagnostics [PR91134] Message-ID: Reply-To: Jakub Jelinek References: <801f6986dc99c122fb095459fe943dbadd58333c.camel@redhat.com> <1093d0af9045b777cb3994b35070149b5f2f03ee.camel@redhat.com> MIME-Version: 1.0 In-Reply-To: <1093d0af9045b777cb3994b35070149b5f2f03ee.camel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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: Wed, 25 May 2022 12:28:53 -0000 On Tue, May 24, 2022 at 09:59:03AM -0400, David Malcolm wrote: > > Ideally we'd have an automated check that the fix-it hint fixes the > > code, but failing that, I like to have at least some DejaGnu test > > coverage for fix-it hints - something like the tests in > > gcc.dg/fixits.c > > or gcc.dg/semicolon-fixits.c, perhaps? Done, see another mail. > Also, what does the output from: > -fdiagnostics-generate-patch > look like? That's usually the best way of checking if we're generating > good fix-it hints. --- pr91134.c +++ pr91134.c @@ -10,19 +10,19 @@ struct X *pointer = &x; struct Y *yp = &y; struct X **pointerpointer = &pointer; - int i = *pointerpointer->member; /* { dg-error "'pointerpointer' is a pointer to pointer; did you mean to dereference it before applying '->' to it\\\?" } */ + int i = *(*pointerpointer)->member; /* { dg-error "'pointerpointer' is a pointer to pointer; did you mean to dereference it before applying '->' to it\\\?" } */ /* { dg-begin-multiline-output "" } int i = *pointerpointer->member; ^~ (* ) { dg-end-multiline-output "" } */ - int j = pointer.member; /* { dg-error "'pointer' is a pointer; did you mean to use '->'\\\?" } */ + int j = pointer->member; /* { dg-error "'pointer' is a pointer; did you mean to use '->'\\\?" } */ /* { dg-begin-multiline-output "" } int j = pointer.member; ^ -> { dg-end-multiline-output "" } */ - int k = yp->x->member; /* { dg-error "'yp->x' is a pointer to pointer; did you mean to dereference it before applying '->' to it\\\?" } */ + int k = (*yp->x)->member; /* { dg-error "'yp->x' is a pointer to pointer; did you mean to dereference it before applying '->' to it\\\?" } */ /* { dg-begin-multiline-output "" } int k = yp->x->member; ^~ The second and third change actually fix those issues and make it compile, the first one will generate a different error, because the right change in that case is int i = (*pointerpointer)->member; but guessing that in the compiler would be too hard, when parsing pointerpointer->member we really don't know that there is * before it... Jakub