From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by sourceware.org (Postfix) with ESMTPS id 28C143858D3C for ; Wed, 1 Mar 2023 03:01:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 28C143858D3C 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=1677639689; x=1709175689; h=from:to:cc:in-reply-to:subject:mime-version: content-transfer-encoding:references:message-id:date; bh=nGhn8tuS0txUPqPCNvUkXwon666E528bKcOWBvmbaXY=; b=m/lnL6BfiP+zTZqtBrhRvuyy2YvK6MoHihEs4M83x0U2bNDCv+3RXxVM /IhFP7uyGfoKalky71M1bLgguGaeT3xuABy841DIwcSLzN9wvFxmCELfh RuU1+/dp8j4AgUQwAep2MlWD62uHA7DIeiKNOQvxFXQE4JY42XL/h7pIb oNRwu0psq/5Fu+BLOAYtXGLLsaqdlHH+LeUAYojtLAB/ogtkL8kz+qygZ WgKtH6BL3sNvoFzYRT8yMR0K0TYWKdAAiZvYwmRYy+9l32wHCKejrBVZn 1d0uYindkr7bUrsao7kUmBSUyjEAB1Bi8frEOUz0gD8nBk08MEaFGQq8/ w==; From: Hans-Peter Nilsson To: David Malcolm CC: In-Reply-To: <9bc0171b3a54d691324cdaf202f5b1aae0829e7d.camel@redhat.com> (message from David Malcolm on Tue, 28 Feb 2023 21:25:34 -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> Message-ID: <20230301030123.A0A2B20438@pchp3.se.axis.com> Date: Wed, 1 Mar 2023 04:01:23 +0100 X-Spam-Status: No, score=-11.3 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 > Date: Tue, 28 Feb 2023 21:25:34 -0500 > On Wed, 2023-03-01 at 01:59 +0100, Hans-Peter Nilsson wrote: > > > From: David Malcolm > > > Date: Tue, 28 Feb 2023 14:12:47 -0500 > > > > > On Tue, 2023-02-28 at 19:47 +0100, Hans-Peter Nilsson wrote: > > > > Ok to commit? > > > > -- >8 -- > > > > Investigating analyzer tesstsuite errors for cris-elf. The same > > > > are > > > > seen for pru-elf according to posts to gcc-testresults@. > > > > > > > > For glibc, errno is #defined as: > > > > extern int *__errno_location (void) __THROW __attribute_const__; > > > > # define errno (*__errno_location ()) > > > > while for newlib in its default configuration, it's: > > > > #define errno (*__errno()) > > > > extern int *__errno (void); > > > > > > We're already handling ___errno (three underscores) for Solaris as > > > of > > > 7c9717fcb5cf94ce1e7ef5c903058adf9980ff28; does it fix the issue if > > > you > > > add __errno (two underscores) to analyzer/kf.cc's > > > register_known_functions in an analogous way to that commit? (i.e. > > > wiring it up to kf_errno_location, "teaching" the analyzer that > > > that > > > function returns a pointer to the "errno region") > > > > But...there's already "support" for two underscores since > > the commit you quote, so I guess not. > > Is there? That commit adds support for: > __error > but not for: > __errno > unless there's something I'm missing. No, it's me. Apparently I can't spot the difference between error and errno. Sorry. It's nice to know that the const-attribute (to signal that the pointer points to a constant location) works automatically, i.e. the Solaris and glibc definitions should not (no longer?) be needed - unless there's other errno-analyzing magic elsewhere too. Either way, since there's specific support for this errno kind of thing, that certainly works for me. The patch gets smaller too. :) So, how's this instead, pending full testing (only analyzer.exp spot-tested)? -- >8 -- 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 | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/analyzer/kf.cc b/gcc/analyzer/kf.cc index 3a91b6bd6ebb..bfb9148f9ae7 100644 --- a/gcc/analyzer/kf.cc +++ b/gcc/analyzer/kf.cc @@ -1036,6 +1036,7 @@ register_known_functions (known_function_manager &kfm) 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