From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 831EC3858D33 for ; Wed, 1 Mar 2023 02:25:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 831EC3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677637538; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ycncYm4R/mDKyeI6PdJuuy3Flov/wtYyp+2MKvXOLuw=; b=J/NaQUl0E1ZfTj73ip7ZbgCJb5EpZel1644K3RFDkq/wkXDePpUUOdvUVorTlf9RIDkSv6 9hBAGkijv8ZOTyjRwoSEgPHpGAIutImTcNDd+e6AlUPxO4PJ/k3y/QJo9y3EEFJEp7kVJB Ju74U2sR59Z2n+xl7wzYLldoTYGwpW8= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-125-XhZr_0AOO0qtoNz11D0wTg-1; Tue, 28 Feb 2023 21:25:37 -0500 X-MC-Unique: XhZr_0AOO0qtoNz11D0wTg-1 Received: by mail-qk1-f200.google.com with SMTP id q25-20020a37f719000000b00742bfdd63ecso3737412qkj.4 for ; Tue, 28 Feb 2023 18:25:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677637536; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ycncYm4R/mDKyeI6PdJuuy3Flov/wtYyp+2MKvXOLuw=; b=aGhoXlSJyen3lUtT0/Bn7D6+t38O2CS+RWj+a9uN0k2Otd65zvsGqwQYpWL82rYsCZ G7nC/nvc47N+aqk360wbq4dwD/7eDwsF8n7Dlr1J751nFQ5N2I4z7fYzHDX6ruCBKPfu ZO1FMKNwzn6YkuW91Bk2F4F/b2ZZrO54I7NVnB+i1bq5hus4J1fBZxl8irtNJiJ+CwHD jH/MbqA2E5U8F3wlpF8bVg/bMk24/pRxQ5RVYvps+6zubRCUzPDQ6NQAXhlKYrDBNfI5 eIWxCD1D7BYCee1ci5nWpU9s+yQDV58MiaQe0xxmXmFm3RB3jEELgaj51gCRWAX8zIgj 8UpQ== X-Gm-Message-State: AO0yUKUHuI83pbFT+tDmwNXBcfKJdE1S0qFtuu+qYAKXQ598nIdT+9J0 +Cn2rxGzBmy+jRzxMG4y1APvgOQ97Y2/Ncx/1ajx4bED+OHzy469AD0MzqS2IRZ1VxhCTLQve5s 7cFWTFQXTAe9/R9IU2kV5Z4g= X-Received: by 2002:a05:622a:15c2:b0:3bf:d6ba:590b with SMTP id d2-20020a05622a15c200b003bfd6ba590bmr8340162qty.65.1677637536091; Tue, 28 Feb 2023 18:25:36 -0800 (PST) X-Google-Smtp-Source: AK7set8v3skpumNgQs4wec7p9L4p4fkVZ3gBNlKDc3t7E8tr599YfZieWFLOMHUqnfLZEiHFb/9FYQ== X-Received: by 2002:a05:622a:15c2:b0:3bf:d6ba:590b with SMTP id d2-20020a05622a15c200b003bfd6ba590bmr8340147qty.65.1677637535761; Tue, 28 Feb 2023 18:25:35 -0800 (PST) Received: from t14s.localdomain (c-73-69-212-193.hsd1.ma.comcast.net. [73.69.212.193]) by smtp.gmail.com with ESMTPSA id x16-20020ac87a90000000b003b9b41a32b7sm7423582qtr.81.2023.02.28.18.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 18:25:35 -0800 (PST) Message-ID: <9bc0171b3a54d691324cdaf202f5b1aae0829e7d.camel@redhat.com> Subject: Re: [PATCH 1/2] testsuite: Fix analyzer errors for newlib-errno From: David Malcolm To: Hans-Peter Nilsson Cc: gcc-patches@gcc.gnu.org Date: Tue, 28 Feb 2023 21:25:34 -0500 In-Reply-To: <20230301005937.632A42042E@pchp3.se.axis.com> References: <20230228184735.24E6E20438@pchp3.se.axis.com> <6bc39adefb2af674338a73408f75733b36ccbe0b.camel@redhat.com> <20230301005937.632A42042E@pchp3.se.axis.com> User-Agent: Evolution 3.44.4 (3.44.4-1.fc36) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00,BODY_8BITS,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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: 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 >=20 > > On Tue, 2023-02-28 at 19:47 +0100, Hans-Peter Nilsson wrote: > > > Ok to commit? > > > -- >8 -- > > > Investigating analyzer tesstsuite errors for cris-elf.=C2=A0 The same > > > are > > > seen for pru-elf according to posts to gcc-testresults@. > > >=20 > > > For glibc, errno is #defined as: > > > =C2=A0extern int *__errno_location (void) __THROW __attribute_const__= ; > > > =C2=A0# define errno (*__errno_location ()) > > > while for newlib in its default configuration, it's: > > > =C2=A0#define errno (*__errno()) > > > =C2=A0extern int *__errno (void); > >=20 > > We're already handling ___errno (three underscores) for Solaris as > > of > > 7c9717fcb5cf94ce1e7ef5c903058adf9980ff28; does it fix the issue if > > you=20 > > add __errno (two underscores) to analyzer/kf.cc's=20 > > register_known_functions in an analogous way to that commit?=C2=A0 (i.e= . > > wiring it up to kf_errno_location, "teaching" the analyzer that > > that > > function returns a pointer to the "errno region") >=20 > But...there's already "support" for two underscores since > the commit you quote, so I guess not.=C2=A0=C2=A0 Is there? That commit adds support for: __error but not for: __errno unless there's something I'm missing. > I strongly believe > "the critical difference is that __attribute__ > ((__const__))" because I indeed proved it by adding it to > the newlib definition. >=20 > 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). >=20 > It looks like that definition was added for good measure > along with the Solaris definition (that has the > attribute-const) but never tested.=C2=A0 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. :( The comments by Rainer in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107807 suggests that it did fix stuff on Solaris and OS X. Sorry if I'm missing something here, I'm not very familiar with newlib. Dave >=20 > brgds, H-P >=20 > >=20 > > Dave > >=20 > > >=20 > > > 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).=C2=A0 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. > > >=20 > > > 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. > > >=20 > > > testsuite: > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * gcc.dg/analyzer/call-sum= maries-errno.c: Expect UNKNOWN > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 for newlib after having se= t errno. > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * gcc.dg/analyzer/errno-1.= c: Ditto. > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * gcc.dg/analyzer/isatty-1= .c: Skip for newlib targets. > > > --- > > > =C2=A0gcc/testsuite/gcc.dg/analyzer/call-summaries-errno.c | 3 ++- > > > =C2=A0gcc/testsuite/gcc.dg/analyzer/errno-1.c=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 3 ++- > > > =C2=A0gcc/testsuite/gcc.dg/analyzer/isatty-1.c=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 2 +- > > > =C2=A03 files changed, 5 insertions(+), 3 deletions(-) > > >=20 > > > 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) > > > =C2=A0=C2=A0 sets_errno (y); > > > =C2=A0=C2=A0 sets_errno (y); > > > =C2=A0 > > > -=C2=A0 __analyzer_eval (errno =3D=3D y); /* { dg-warning "TRUE" } */= =C2=A0=20 > > > +=C2=A0 __analyzer_eval (errno =3D=3D y); /* { dg-warning "TRUE" "err= no is > > > at > > > a constant location" { target { ! newlib } } } */ > > > +=C2=A0 /* { dg-warning "UNKNOWN" "errno is not known to be at a > > > constant > > > location" { target { newlib } } .-1 } */ > > > =C2=A0} > > > 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) > > > =C2=A0{ > > > =C2=A0=C2=A0 __analyzer_eval (errno =3D=3D val); /* { dg-warning "UNK= NOWN" } */ > > > =C2=A0=C2=A0 errno =3D val; > > > -=C2=A0 __analyzer_eval (errno =3D=3D val); /* { dg-warning "TRUE" } = */ > > > +=C2=A0 __analyzer_eval (errno =3D=3D val); /* { dg-warning "TRUE" "e= rrno > > > is > > > at a constant location" { target { ! newlib } } } */ > > > +=C2=A0 /* { dg-warning "UNKNOWN" "errno is not known to be at a > > > constant > > > location" { target { newlib } } .-1 } */ > > > =C2=A0=C2=A0 external_fn (); > > > =C2=A0=C2=A0 __analyzer_eval (errno =3D=3D val); /* { dg-warning "UNK= NOWN" } > > > */=C2=A0=20 > > > =C2=A0} > > > 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 } } */ > > > =C2=A0 > > > =C2=A0#include > > > =C2=A0#include "analyzer-decls.h" > >=20 >=20