public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-6496] analyzer: fix reproducer for PR 93375
@ 2020-02-07 0:37 David Malcolm
0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2020-02-07 0:37 UTC (permalink / raw)
To: gcc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 2929 bytes --]
https://gcc.gnu.org/g:13f5b93e6453d121abc15c718dfcc588aca976c3
commit r10-6496-g13f5b93e6453d121abc15c718dfcc588aca976c3
Author: David Malcolm <dmalcolm@redhat.com>
Date: Thu Feb 6 14:17:48 2020 -0500
analyzer: fix reproducer for PR 93375
Reproducing the ICE in PR analyzer/93375 required some kind of
analyzer diagnostic occurring after a call with fewer arguments
than required by the callee.
The testcase used __builtin_memcpy with a NULL argument for this.
On x86_64-pc-linux-gnu this happened to be already optimized into:
_4 = MEM <unsigned int> [(char * {ref-all})0B];
MEM <unsigned int> [(char * {ref-all})rl_1] = _4;
by the time of the analyzer pass, leading to the diagnostic in question
being:
warning: dereference of NULL ârlâ [CWE-690] [-Wanalyzer-null-dereference]
On other targets e.g. arm-unknown-linux-gnueabi, the builtin isn't
optimized at the time of the analyzer pass, leading to this diagnostic
instead:
warning: use of NULL ârlâ where non-null expected [CWE-690] [-Wanalyzer-null-argument]
<built-in>: note: argument 1 of â__builtin_memcpyâ must be non-null
This patch fixes the test case by using a custom function marked as
nonnull. I manually verified that it still reproduces the ICE if the
patch for the PR is reverted.
gcc/testsuite/ChangeLog:
PR analyzer/93375
* gcc.dg/analyzer/pr93375.c: Rework test case to avoid per-target
differences in how __builtin_memcpy has been optimized at the time
the analyzer runs.
Diff:
---
gcc/testsuite/ChangeLog | 7 +++++++
gcc/testsuite/gcc.dg/analyzer/pr93375.c | 4 +++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f6f12dd..a6fbf5b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,12 @@
2020-02-06 David Malcolm <dmalcolm@redhat.com>
+ PR analyzer/93375
+ * gcc.dg/analyzer/pr93375.c: Rework test case to avoid per-target
+ differences in how __builtin_memcpy has been optimized at the time
+ the analyzer runs.
+
+2020-02-06 David Malcolm <dmalcolm@redhat.com>
+
* gcc.dg/analyzer/torture/intptr_t.c: New test.
2020-02-06 Segher Boessenkool <segher@kernel.crashing.org>
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr93375.c b/gcc/testsuite/gcc.dg/analyzer/pr93375.c
index 93a3e87..f610854 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pr93375.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pr93375.c
@@ -1,5 +1,7 @@
/* { dg-additional-options "-Wno-implicit-int" } */
+extern void foo (void *) __attribute__((nonnull));
+
void
en (jm)
{
@@ -11,5 +13,5 @@ p2 ()
char *rl = 0;
en ();
- __builtin_memcpy (rl, 0, sizeof (0)); /* { dg-warning "dereference of NULL" } */
+ foo (rl); /* { dg-warning "use of NULL 'rl' where non-null expected" } */
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-02-07 0:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-07 0:37 [gcc r10-6496] analyzer: fix reproducer for PR 93375 David Malcolm
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).