From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by sourceware.org (Postfix) with ESMTPS id 01DDF3858D33 for ; Wed, 1 Mar 2023 15:36:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 01DDF3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=axis.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=axis.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1677685008; x=1709221008; h=from:to:cc:in-reply-to:subject:mime-version: content-transfer-encoding:references:message-id:date; bh=BuoZrjo7qzF+3U0S37NB5xgt6RAPG0J4JfSrVvJwzSA=; b=oKrk8XBg2Qh72abOmt7vN9uH6tzmOPDb9NrU3V2aBt3UkxvDdlyGt3d7 jVi2FC71X1GJ7feAvx4EeXHrrLrOKaDs4erSJzb7+tIOZU9CGRYlAIZHd /n14xikVWIW74fAsNFnEwAN8VIfn9eb/IqyOrJ+wO4jtUiquFekDxG0lT FLywv15TnIfnqbY27Fb9VBLi3juJer36Snr/KmPQI+bS+iPmB8gd5DNOH 5OBRwq4DXfu9p54AMOlfFW91VKYzXu/0sLlOt26YpIAxURsw1vv22CBd7 HGhc52heBIRX09CbkhNnioanui03t9tCcJa6Xvjb6QcJR6onPRUltrkUk w==; From: Hans-Peter Nilsson To: David Malcolm CC: In-Reply-To: (message from David Malcolm on Wed, 01 Mar 2023 08:32:13 -0500) Subject: Re: [PATCH 1/2] testsuite: Fix analyzer errors for newlib-errno MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT References: <20230228184735.24E6E20438@pchp3.se.axis.com> <6bc39adefb2af674338a73408f75733b36ccbe0b.camel@redhat.com> <20230301005937.632A42042E@pchp3.se.axis.com> <9bc0171b3a54d691324cdaf202f5b1aae0829e7d.camel@redhat.com> <20230301030123.A0A2B20438@pchp3.se.axis.com> Message-ID: <20230301153646.9FF6220426@pchp3.se.axis.com> Date: Wed, 1 Mar 2023 16:36:46 +0100 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_PASS,SPF_PASS,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: > From: David Malcolm > Cc: gcc-patches@gcc.gnu.org > Date: Wed, 01 Mar 2023 08:32:13 -0500 > Also, the analyzer uses region_model::set_errno in various > known_function implementations, e.g. for functions that can succeed or > fail, to set errno on the "failure" execution path to a new symbolic > value that tests as > 0. Ha, there's indeed errno-analyzing magic. :) (That's the level you get when your first impression of source code is by tracing through failing test-cases...) > > So, how's this instead, pending full testing (only > > analyzer.exp spot-tested)? > > Looks good, though how about adding a mention of newlib to the comment > immediately above (the one that talks about Solaris and OS X)? I deliberately didn't, as the format of that comment seemed to ask for redundantly repeating the definition for each system (telling exactly how the #define looks etc.), and I thought the heading "Other implementations of C standard library" should have been sufficient, assuming access to the git log when there's interest in more than the first lines. But I hear you so this is what I intend to commit later today, just keeping the added comment as brief as reasonable: "analyzer: Support errno for newlib Without this definition, the errno definition for newlib isn't recognized as such, and these tests fail for newlib targets: FAIL: gcc.dg/analyzer/call-summaries-errno.c (test for warnings, line 16) FAIL: gcc.dg/analyzer/call-summaries-errno.c (test for excess errors) FAIL: gcc.dg/analyzer/errno-1.c (test for warnings, line 20) FAIL: gcc.dg/analyzer/errno-1.c (test for excess errors) FAIL: gcc.dg/analyzer/isatty-1.c (test for warnings, line 31) FAIL: gcc.dg/analyzer/isatty-1.c (test for warnings, line 35) FAIL: gcc.dg/analyzer/isatty-1.c (test for warnings, line 46) FAIL: gcc.dg/analyzer/isatty-1.c (test for warnings, line 56) FAIL: gcc.dg/analyzer/isatty-1.c (test for excess errors) gcc/analyzer: * kf.cc (register_known_functions): Add __errno function for newlib. --- gcc/analyzer/kf.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/analyzer/kf.cc b/gcc/analyzer/kf.cc index 3a91b6bd6ebb..ed5f70398e1d 100644 --- a/gcc/analyzer/kf.cc +++ b/gcc/analyzer/kf.cc @@ -1033,9 +1033,11 @@ register_known_functions (known_function_manager &kfm) and OS X like this: extern int * __error(void); #define errno (*__error()) + and similarly __errno for newlib. Add these as synonyms for "__errno_location". */ kfm.add ("___errno", make_unique ()); kfm.add ("__error", make_unique ()); + kfm.add ("__errno", make_unique ()); } /* Language-specific support functions. */ -- 2.30.2 > Thanks for fixing this Thank *you* for the review! brgds, H-P