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 BAE6F3858D33 for ; Tue, 28 Feb 2023 19:12:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BAE6F3858D33 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=1677611573; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BLlSjDY9o+bzYVcTqJEWqIPItbVmnmWX7RTFYfLI4YU=; b=RI7ZDgZJc0HMACQ9fiB+ZG/1XGOt29no5cMTlP580czoGCn/X0eFjMiMOEv8Lyw4bjlcyz 8Ada6F/Sn5k66L2mUmxl7YEuGxR+7G8g3+G5dl9IeF5K/hVUzw8ERNA1muNimhf0kQidSs Xy3ABmwFsKo1wfLiRYIs0BH57qV2M+c= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-453-rVTs3oYsO-K8fjPl7Fotbg-1; Tue, 28 Feb 2023 14:12:50 -0500 X-MC-Unique: rVTs3oYsO-K8fjPl7Fotbg-1 Received: by mail-qt1-f198.google.com with SMTP id o10-20020a05622a138a00b003bfdabf3b89so3466985qtk.13 for ; Tue, 28 Feb 2023 11:12:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677611569; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=BLlSjDY9o+bzYVcTqJEWqIPItbVmnmWX7RTFYfLI4YU=; b=SPWMOG8YdRpTR/fDv9incwpaZoZ6fF7bR5XZ+/KUKuop51U0r4YmV8Yfr9duVG5Ofn w2Bo/Zp/OGj7w575ZDugp9j5gQnyr5nQj3GYaK3m4FwNrnl67kQ6zzEAVUy43+lhhL9l EUUPYyBEX09uoE8PAJB4KWqHRAh+/ReUKDmLETiU9DFZsrRWwRPSPhLdQ7+D1CVLgQej Qkj/lGVwD2M0Udm69rcjPiTvVdvPTOzeJRGVF8vFx4Io/o1GYfZECErFQtRBGwyeA111 i+FWPE4VANXDXrhsgZ/eDQ7DlHS1OBCiqjJlMxBAOD8bX4wAPSKrWcYOxrrz9pjfrhIH 1+uQ== X-Gm-Message-State: AO0yUKUEKMvQcRuXN3SXikz4C2UEtByf/O9+c6GZ4uO0AaIE9hhQNN2q sqwugdFcw0LrRLYwvtXRaysdbRmdRHM8aIJhVbIlxiNS6a6053xLPw09/amy1eiuAFqm3roXvV/ QSqW5PRJxUg1pF//Idw== X-Received: by 2002:a05:622a:1829:b0:3b8:6763:c25f with SMTP id t41-20020a05622a182900b003b86763c25fmr6904179qtc.13.1677611569244; Tue, 28 Feb 2023 11:12:49 -0800 (PST) X-Google-Smtp-Source: AK7set9Nss2qiv5vIe+RVeQTY8LZNW5NapYRey6LzJMKZnjhIr+jpuKmUXsYdwYh7kSi3tAhuPH9XQ== X-Received: by 2002:a05:622a:1829:b0:3b8:6763:c25f with SMTP id t41-20020a05622a182900b003b86763c25fmr6904151qtc.13.1677611568934; Tue, 28 Feb 2023 11:12:48 -0800 (PST) Received: from t14s.localdomain (c-73-69-212-193.hsd1.nh.comcast.net. [73.69.212.193]) by smtp.gmail.com with ESMTPSA id e22-20020ac84b56000000b003b646123691sm6923301qts.31.2023.02.28.11.12.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 11:12:48 -0800 (PST) Message-ID: <6bc39adefb2af674338a73408f75733b36ccbe0b.camel@redhat.com> Subject: Re: [PATCH 1/2] testsuite: Fix analyzer errors for newlib-errno From: David Malcolm To: Hans-Peter Nilsson , gcc-patches@gcc.gnu.org Date: Tue, 28 Feb 2023 14:12:47 -0500 In-Reply-To: <20230228184735.24E6E20438@pchp3.se.axis.com> References: <20230228184735.24E6E20438@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,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 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); We're already handling ___errno (three underscores) for Solaris as of 7c9717fcb5cf94ce1e7ef5c903058adf9980ff28; does it fix the issue if you=C2= =A0 add __errno (two underscores) to analyzer/kf.cc's=20 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") Dave >=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=C2=A0* gcc.dg/analyzer/call-su= mmaries-errno.c: Expect UNKNOWN > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0for newlib after having s= et errno. > =C2=A0=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=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" "errno i= s 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 "UNKNOWN= " } */ > =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" "errno= 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 "UNKNOWN= " } */=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"