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 8543B3858D3C for ; Wed, 1 Mar 2023 23:43:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8543B3858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677714235; 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:in-reply-to:in-reply-to: references:references; bh=8DMZR/cEdxQGBksQE2dx/IWTLucCUzTMJ7sp/1+Upls=; b=De0qBHFFk6KxYK8G1pF11eFO2Ei4t7OD0JWy14RmeSd/EFlczn5xDZPZsEhJSAOGh0MxJC 97NYDJuohdV7XkfjQkS13qaM3f9abPEO/Gc+1GWAxVUjIsocrs/YhX4TyiDz4HvhsJb1oS Vw3zlOZ81pyVWidNOlAayBrqOjN3Yaw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-413-7d2U9n4uP6GK8WWx41z-sQ-1; Wed, 01 Mar 2023 18:43:53 -0500 X-MC-Unique: 7d2U9n4uP6GK8WWx41z-sQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8EADC87B2A0; Wed, 1 Mar 2023 23:43:53 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4EB1E18EC1; Wed, 1 Mar 2023 23:43:53 +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 321Nho2Y3219036 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 2 Mar 2023 00:43:51 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 321Nhnqd3217205; Thu, 2 Mar 2023 00:43:49 +0100 Date: Thu, 2 Mar 2023 00:43:48 +0100 From: Jakub Jelinek To: Andrew Pinski Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix PR 108980: note without warning due to array bounds check Message-ID: Reply-To: Jakub Jelinek References: <20230301232500.2622240-1-apinski@marvell.com> MIME-Version: 1.0 In-Reply-To: <20230301232500.2622240-1-apinski@marvell.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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=-9.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_H2,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 Wed, Mar 01, 2023 at 03:25:00PM -0800, Andrew Pinski via Gcc-patches wrote: > The problem here is after r13-4748-g2a27ae32fabf85, in some > cases we were calling inform without a corresponding warning. > This changes the logic such that we only cause that to happen > if there was a warning happened before hand. > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. > > gcc/ChangeLog: > > PR tree-optmization/108980 s/optmization/optimization/ > * gimple-array-bounds.cc (array_bounds_checker::check_array_ref): > Reorgnize the call to warning for not strict flexible arrays > to be before the check of warned. > --- > gcc/gimple-array-bounds.cc | 41 ++++++++++++++++++++++++-------------- > 1 file changed, 26 insertions(+), 15 deletions(-) > > diff --git a/gcc/gimple-array-bounds.cc b/gcc/gimple-array-bounds.cc > index 66fd46e9b6c..469baecaa1a 100644 > --- a/gcc/gimple-array-bounds.cc > +++ b/gcc/gimple-array-bounds.cc > @@ -397,27 +397,38 @@ array_bounds_checker::check_array_ref (location_t location, tree ref, > "of an interior zero-length array %qT")), > low_sub, artype); > > - if (warned || out_of_bound) > + if (warned && dump_file && (dump_flags & TDF_DETAILS)) > { > - if (warned && dump_file && (dump_flags & TDF_DETAILS)) > + fprintf (dump_file, "Array bound warning for "); > + dump_generic_expr (MSG_NOTE, TDF_SLIM, ref); > + fprintf (dump_file, "\n"); > + } > + > + /* Issue warnings for -Wstrict-flex-arrays according to the level of > + flag_strict_flex_arrays. */ > + if (out_of_bound && warn_strict_flex_arrays > + && (sam == special_array_member::trail_0 > + || sam == special_array_member::trail_1 > + || sam == special_array_member::trail_n) > + && DECL_NOT_FLEXARRAY (afield_decl)) > + { > + bool warned1; > + warned1 = warning_at (location, OPT_Wstrict_flex_arrays, Why the separate declaration and assignment? bool warned1 = warning_at (location, OPT_Wstrict_flex_arrays, "trailing array %qT should not be used as a flexible " "array member", artype); looks better. > + "trailing array %qT should not be used as " > + "a flexible array member", > + artype); > + > + if (warned1 && dump_file && (dump_flags & TDF_DETAILS)) > { > - fprintf (dump_file, "Array bound warning for "); > + fprintf (dump_file, "Not Flexible array bound warning for "); Why the capitalization of F ? Though, I think the wording isn't best anyway. Perhaps "Trailing non flexible-like array bound warning for" ? That is what DECL_NOT_FLEXARRAY is after all, trailing array which isn't handled like flexible array. > dump_generic_expr (MSG_NOTE, TDF_SLIM, ref); > fprintf (dump_file, "\n"); > } > + warned |= warned1; > + } > Jakub