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 CE0F63858D33 for ; Wed, 1 Mar 2023 00:59:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CE0F63858D33 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=1677632381; x=1709168381; h=from:to:cc:in-reply-to:subject:mime-version: content-transfer-encoding:references:message-id:date; bh=fUPiZw5ZkVC+Nr2S67a/6FDEYV1RS+SWLTPUculWubI=; b=iAZBMGr8j+Weakd2dFbmV9RQBkhJ+8R8PTXl4sPkWhm05YqjlhYtmnbq oDums6wyFHKRzQZUOOhxE9DzyC+PhWbvy0OTlPn7tkag2RtLI7xHvGU/k foW14Xil369PIDCGL2JVokeSLNPxgUYKvds7FjjFlKbhg+8g2MD/FwDdY yFHkysYNQEqoQoV17bvOsJ0t55TVkP0qWOl6X3OWvXfZpB2f+3yWQ64e8 qE3ECpMDVB4yRo3TK2kZMneL7ZBTqkzWKZnKSx2IC5L3HJ6jggjtwevxe +vyHLzlPtYyDJ71dIT+M33txQpIA+k5RSihJYZ+lnTZKQkWGmPR7ly9QH Q==; From: Hans-Peter Nilsson To: David Malcolm CC: In-Reply-To: <6bc39adefb2af674338a73408f75733b36ccbe0b.camel@redhat.com> (message from David Malcolm on Tue, 28 Feb 2023 14:12:47 -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> Message-ID: <20230301005937.632A42042E@pchp3.se.axis.com> Date: Wed, 1 Mar 2023 01:59:37 +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 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. I strongly believe "the critical difference is that __attribute__ ((__const__))" because I indeed proved it by adding it to the newlib definition. I doubt these tests actually *pass* for OS X, because that one looks identical to the newlib definition as quoted in that commit (compare to the newlib one I pasted in the quote above). It looks like that definition was added for good measure along with the Solaris definition (that has the attribute-const) but never tested. Sorry, I don't have an OS X to test it myself and according to a popular search engine(...) nobody has posted gcc-testresults@ for anything "apple" since gcc-4.7 era. :( brgds, H-P > > Dave > > > > > The critical difference is that __attribute__ ((__const__)), > > where glibc says that the caller will see the same value on > > all calls (from the same context; read: same thread). I'm > > not sure the absence of __attribute__ ((__const__)) for the > > newlib definition is deliberate, but I guess it can. > > Either way, without the "const" attribute, it can't be known > > that the same location will be returned the next time, so > > analyzer-tests that depend the value being known it should > > see UNKNOWN rather than TRUE, that's why the deliberate > > check for UNKNOWN rather than xfailing the test. > > > > For isatty-1.c, it's the same problem, but here it'd be > > unweildy with the extra dg-lines, so better just skip it for > > newlib targets. > > > > testsuite: > > * gcc.dg/analyzer/call-summaries-errno.c: Expect UNKNOWN > > for newlib after having set errno. > > * gcc.dg/analyzer/errno-1.c: Ditto. > > * gcc.dg/analyzer/isatty-1.c: Skip for newlib targets. > > --- > > gcc/testsuite/gcc.dg/analyzer/call-summaries-errno.c | 3 ++- > > gcc/testsuite/gcc.dg/analyzer/errno-1.c | 3 ++- > > gcc/testsuite/gcc.dg/analyzer/isatty-1.c | 2 +- > > 3 files changed, 5 insertions(+), 3 deletions(-) > > > > diff --git a/gcc/testsuite/gcc.dg/analyzer/call-summaries-errno.c > > b/gcc/testsuite/gcc.dg/analyzer/call-summaries-errno.c > > index e4333b30bb77..cf4d9f7141e4 100644 > > --- a/gcc/testsuite/gcc.dg/analyzer/call-summaries-errno.c > > +++ b/gcc/testsuite/gcc.dg/analyzer/call-summaries-errno.c > > @@ -13,5 +13,6 @@ void test_sets_errno (int y) > > sets_errno (y); > > sets_errno (y); > > > > - __analyzer_eval (errno == y); /* { dg-warning "TRUE" } */ > > + __analyzer_eval (errno == y); /* { dg-warning "TRUE" "errno is at > > a constant location" { target { ! newlib } } } */ > > + /* { dg-warning "UNKNOWN" "errno is not known to be at a constant > > location" { target { newlib } } .-1 } */ > > } > > diff --git a/gcc/testsuite/gcc.dg/analyzer/errno-1.c > > b/gcc/testsuite/gcc.dg/analyzer/errno-1.c > > index 6b9d28c10799..af0cc3d52a36 100644 > > --- a/gcc/testsuite/gcc.dg/analyzer/errno-1.c > > +++ b/gcc/testsuite/gcc.dg/analyzer/errno-1.c > > @@ -17,7 +17,8 @@ void test_storing_to_errno (int val) > > { > > __analyzer_eval (errno == val); /* { dg-warning "UNKNOWN" } */ > > errno = val; > > - __analyzer_eval (errno == val); /* { dg-warning "TRUE" } */ > > + __analyzer_eval (errno == val); /* { dg-warning "TRUE" "errno is > > at a constant location" { target { ! newlib } } } */ > > + /* { dg-warning "UNKNOWN" "errno is not known to be at a constant > > location" { target { newlib } } .-1 } */ > > external_fn (); > > __analyzer_eval (errno == val); /* { dg-warning "UNKNOWN" } */ > > } > > diff --git a/gcc/testsuite/gcc.dg/analyzer/isatty-1.c > > b/gcc/testsuite/gcc.dg/analyzer/isatty-1.c > > index 389d2cdf3f18..450a7d71990d 100644 > > --- a/gcc/testsuite/gcc.dg/analyzer/isatty-1.c > > +++ b/gcc/testsuite/gcc.dg/analyzer/isatty-1.c > > @@ -1,4 +1,4 @@ > > -/* { dg-skip-if "" { powerpc*-*-aix* } } */ > > +/* { dg-skip-if "" { powerpc*-*-aix* || newlib } } */ > > > > #include > > #include "analyzer-decls.h" >