From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by sourceware.org (Postfix) with ESMTPS id 4FD833856088 for ; Tue, 14 Jun 2022 13:33:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4FD833856088 Received: by mail-qt1-x831.google.com with SMTP id j8so6029495qtn.13 for ; Tue, 14 Jun 2022 06:33:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=fTi0AzjbD4Cl5nwZWj0bQqwaYEY02ZCY8vANRb8k1kk=; b=kShTLx1fFaMZuK6XTbGnS0JJAxSLwDgEUIvaPk6RryXgkqFlvelfCTFpFXtzWtHpec lb/NsdGiEnkQ+ALts7vdSl4IOAloN3QpI47ygdi0+3wvhiOEefUv6+LhfOmHt2WaTboI A4/yjReA8mGXCtQIzSDnvh39d5zQ5evrhixbszGR1mUr2PbLQE/8NW0MiWNnSIqygQC0 vl5XBcG0SpvGiGteA8TTwOSPyzvjsWY2F2cS6b6t4quzZYoSPOFcdXHTLwKwGyC26m43 3ITrYYDrTjcayo1Qi41kR0DGjdGLdnp0zZEXub0bXfPfZMc3WgOtSFd5H3tZi50k+e0x 03hg== X-Gm-Message-State: AOAM531ZUkeKm3tbYnlVK21kmq9CmgvxkMm7ep/+10PCswXK5wWObEl4 XQilw3aL+PggzMcu/VcSd7x3fzVBPJj6NpCezrw= X-Google-Smtp-Source: ABdhPJwFV4GZMoTX6bs7oYpwtdE67tOyVPtPRRpFuS7YngVo5dWTUH/k18kWL1+Sj6qPabYLs4MKojSKVE7wlloSV5E= X-Received: by 2002:ac8:59c5:0:b0:304:fe09:6c33 with SMTP id f5-20020ac859c5000000b00304fe096c33mr4102445qtf.224.1655213620257; Tue, 14 Jun 2022 06:33:40 -0700 (PDT) MIME-Version: 1.0 References: <7390933.EvYhyI6sBW@fomalhaut> <2514895.Lt9SDvczpP@fomalhaut> In-Reply-To: <2514895.Lt9SDvczpP@fomalhaut> From: Richard Biener Date: Tue, 14 Jun 2022 15:33:28 +0200 Message-ID: Subject: Re: [PATCH] Do not erase warning data in gimple_set_location To: Eric Botcazou Cc: Martin Sebor , GCC Patches Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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: Tue, 14 Jun 2022 13:33:43 -0000 On Tue, Jun 14, 2022 at 12:49 PM Eric Botcazou wrote= : > > > Hmm, I think instead of special-casing UNKNOWN_LOCATION > > what gimple_set_location should probably do is either not copy > > warnings at all or union them. Btw, gimple_set_location also > > removes a previously set BLOCK (but gimple_set_block preserves > > the location locus and diagnostic override). > > > > So I'd be tempted to axe the copy_warning () completely here. > > The first thing I tried, but it regressed the original testcase IIRC. > > Even my minimal patch manages to break bootstrap on ARM: > > buildslave/workspace/tcwg_gnu_1/abe/snapshots/gcc.git~master/libcpp/lex.c= c: > 1523:9: error: pointer used after =E2=80=98void operator delete(void*, st= d::size_t)=E2=80=99 > [-Werror=3Duse-after-free] > # 00:31:04 make[3]: *** [Makefile:227: lex.o] Error 1 > # 00:31:04 make[2]: *** [Makefile:9527: all-stage3-libcpp] Error 2 > # 00:31:35 make[1]: *** [Makefile:25887: stage3-bubble] Error 2 > # 00:31:35 make: *** [Makefile:1072: all] Error 2 > > /* Don't warn for cases like when a cdtor returns 'this' on ARM. *= / > else if (warning_suppressed_p (var, OPT_Wuse_after_free)) > return; > > because warning-control.cc:copy_warning also clobbers the warning data of= the > destination. We have in cp/decl.cc:maybe_return_this the lines: > > /* Return the address of the object. */ > tree val =3D DECL_ARGUMENTS (current_function_decl); > suppress_warning (val, OPT_Wuse_after_free); > > -Wuse-after-free is suppressed for the location of VAL and the TREE_NO_WA= RNING > bit set on it. But other expressions may have the same location as VAL a= nd > the TREE_NO_WARNING bit _not_ set, so when you call copy_warning (expr, e= xpr) > (we do that a lot after failed folding) for them, copy_warning erases the > warning data of the location. > > I have installed the obvious fixlet after testing on x86-64/Linux, but th= e > decoupling between TREE_NO_WARNING bit and location looks a bit problemat= ic. Thanks - that makes more sense. > > * warning-control.cc (copy_warning) [generic version]: Do not era= se > the warning data of the destination location when the no-warning > bit is not set on the source. > (copy_warning) [tree version]: Return early if TO is equal to FRO= M. > (copy_warning) [gimple version]: Likewise. > testsuite/ > * g++.dg/warn/Wuse-after-free5.C: New test. > > -- > Eric Botcazou