From: Hans-Peter Nilsson <hp@axis.com>
To: <gcc-patches@gcc.gnu.org>
Cc: <dmalcolm@redhat.com>
Subject: [PATCH 1/2] testsuite: Fix analyzer errors for newlib-errno
Date: Tue, 28 Feb 2023 19:47:35 +0100 [thread overview]
Message-ID: <20230228184735.24E6E20438@pchp3.se.axis.com> (raw)
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);
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 <errno.h>
#include "analyzer-decls.h"
--
2.30.2
next reply other threads:[~2023-02-28 18:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-28 18:47 Hans-Peter Nilsson [this message]
2023-02-28 19:12 ` David Malcolm
2023-03-01 0:59 ` Hans-Peter Nilsson
2023-03-01 2:25 ` David Malcolm
2023-03-01 3:01 ` Hans-Peter Nilsson
2023-03-01 13:32 ` David Malcolm
2023-03-01 15:36 ` Hans-Peter Nilsson
2023-03-01 16:02 ` Hans-Peter Nilsson
2023-03-01 23:23 ` Bernhard Reutner-Fischer
2023-03-01 23:54 ` Hans-Peter Nilsson
2023-03-02 0:37 ` Bernhard Reutner-Fischer
2023-03-02 0:58 ` Hans-Peter Nilsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230228184735.24E6E20438@pchp3.se.axis.com \
--to=hp@axis.com \
--cc=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).