From patchwork Mon Feb 5 12:57:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 85304 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0AD683858286 for ; Mon, 5 Feb 2024 12:58:20 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id EF0203858CDA for ; Mon, 5 Feb 2024 12:57:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF0203858CDA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EF0203858CDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707137875; cv=none; b=fGeJmvkKrlyWkzIbRcsPCtW08sDc1sQFOzYQf6/HcdzVn51HYUdrVjIZFS8Yuj03bulSw6TO1IfwOaFY6StiGrT1mFaTrvUlbsCiBsmnrlrgNFVjaMDzW9DCNLYjGL5bqp4/enPvlwDAi+++B6KmbN/De2r8/GtxlSNSq5CpP0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707137875; c=relaxed/simple; bh=it4FPOuHiF39MvDu8/iL6ynph/fA+qcS14Y9p7hiTso=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=aKJueCf96kexaIoDedhNMkjRRdCL9JcP6x5aJkbav+QrGddxpMSTL+VrziAe/JrdEb8GXNteyAtrB5rFbCu4QvsKdexYCthToYzmqTPQuJU6/o7XF7b1AAzFZrnS3Y++4CTQsnFxQNqEtpHwQQBo7gRdyFnnsY6BfMVNPwzUUWg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.4.150] (unknown [10.168.4.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9575F2226F; Mon, 5 Feb 2024 12:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707137872; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=MJwLQFWNhFBzXJ/4+TAv0rR6F+bsXECeIhAOKpuvN40=; b=dwD4DYDM4RArYAPdlBwNN4yI/4e+kHd+NPsG2WqD1yT5kSbjEyzYJJgo49rs6m0BMiV0WR pyGjWvlpnDgYkyMU1SrnaqAUmoJLMuZQV9CQUExzdcOntLxP+hdZ1bh4YfRflMGrmqN7Dg P4mg3LDntkjkXrh4rtnKO3BA4TGZaX8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707137872; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=MJwLQFWNhFBzXJ/4+TAv0rR6F+bsXECeIhAOKpuvN40=; b=BXjOhq6w+6QUy9vmdmkrQBxEGiq6fS18uOZueh0FR2k1PPKyOcOsjrVC6iWDFmFXTYTH6V gc6/3VBtvq0EMdBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707137872; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=MJwLQFWNhFBzXJ/4+TAv0rR6F+bsXECeIhAOKpuvN40=; b=dwD4DYDM4RArYAPdlBwNN4yI/4e+kHd+NPsG2WqD1yT5kSbjEyzYJJgo49rs6m0BMiV0WR pyGjWvlpnDgYkyMU1SrnaqAUmoJLMuZQV9CQUExzdcOntLxP+hdZ1bh4YfRflMGrmqN7Dg P4mg3LDntkjkXrh4rtnKO3BA4TGZaX8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707137872; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=MJwLQFWNhFBzXJ/4+TAv0rR6F+bsXECeIhAOKpuvN40=; b=BXjOhq6w+6QUy9vmdmkrQBxEGiq6fS18uOZueh0FR2k1PPKyOcOsjrVC6iWDFmFXTYTH6V gc6/3VBtvq0EMdBw== Date: Mon, 5 Feb 2024 13:57:52 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: Jakub Jelinek Subject: [PATCH] middle-end/109559 - warning in system header not suppressed MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -0.09 X-Spamd-Result: default: False [-0.09 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-0.98)[-0.983]; MIME_GOOD(-0.10)[text/plain]; NEURAL_SPAM_SHORT(1.49)[0.497]; MISSING_MID(2.50)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_TWO(0.00)[2]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-3.00)[100.00%] X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Message-Id: <20240205125820.0AD683858286@sourceware.org> set_inlining_locations looks at a possible macro expansion location when the location is in a system header but it fails to update its counter when there's no macro involved. The following fixes that. Bootstrapped and tested on x86_64-unknown-linux-gnu. This doesn't fix the observed diagnostic in the PR which I think is now given by design since we diagnose inlined code from a system header into a function not in a system header. But I think it still fixes a bug. The whole set_inlining_locations is a bit pointless since all that matters should be the location of the call (and its system header status) then. I'll also note that -Wno-system-headers doesn't help and we don't have any flag to disable diagnosing inlined-from-system-header code either. Unfortunately this is all from changes done by Martin Sebor so it's difficult to tell the true intention. The code in set_inlining_locations doesn't really do what it documents but fixing (I'll attach the "failed" patch in the PR) will break testcases that test we diagnose inline copies. Anyway - OK for the change below where I don't have any testcase. Thanks, Richard. PR middle-end/109559 * tree-diagnostic.cc (set_inlining_locations): Always increment nsyslocs when loc is in a system header. --- gcc/tree-diagnostic.cc | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/gcc/tree-diagnostic.cc b/gcc/tree-diagnostic.cc index a660c7d0785..e050a6eccf6 100644 --- a/gcc/tree-diagnostic.cc +++ b/gcc/tree-diagnostic.cc @@ -339,24 +339,14 @@ set_inlining_locations (diagnostic_context *, block = BLOCK_SUPERCONTEXT (block); } + if (in_system_header_at (loc)) + ++nsyslocs; + + /* When there is an inlining context use the macro expansion + location for the original location and bump up NSYSLOCS if + it's in a system header since it's not counted above. */ if (ilocs.length ()) - { - /* When there is an inlining context use the macro expansion - location for the original location and bump up NSYSLOCS if - it's in a system header since it's not counted above. */ - location_t sysloc = expansion_point_location_if_in_system_header (loc); - if (sysloc != loc) - { - loc = sysloc; - ++nsyslocs; - } - } - else - { - /* When there's no inlining context use the original location - and set NSYSLOCS accordingly. */ - nsyslocs = in_system_header_at (loc) != 0; - } + loc = expansion_point_location_if_in_system_header (loc); ilocs.safe_push (loc);