public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-1685] testsuite: Add more allocation size tests for conjured svalues [PR110014]
@ 2023-06-10 12:29 Tim Lange
  0 siblings, 0 replies; only message in thread
From: Tim Lange @ 2023-06-10 12:29 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:39adc5eebd61fd276f3f1ef9d7228756a35bd0cb

commit r14-1685-g39adc5eebd61fd276f3f1ef9d7228756a35bd0cb
Author: Tim Lange <mail@tim-lange.me>
Date:   Fri Jun 9 20:08:22 2023 +0200

    testsuite: Add more allocation size tests for conjured svalues [PR110014]
    
    This patch adds the reproducers reported in PR 110014 as test cases. The
    false positives in those cases are already fixed with PR 109577.
    
    2023-06-09  Tim Lange  <mail@tim-lange.me>
    
            PR analyzer/110014
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/analyzer/realloc-pr110014.c: New tests.

Diff:
---
 gcc/testsuite/gcc.dg/analyzer/realloc-pr110014.c | 25 ++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/analyzer/realloc-pr110014.c b/gcc/testsuite/gcc.dg/analyzer/realloc-pr110014.c
new file mode 100644
index 00000000000..d76b8781413
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/realloc-pr110014.c
@@ -0,0 +1,25 @@
+void *realloc (void *, unsigned long)
+  __attribute__((__nothrow__, __leaf__))
+  __attribute__((__warn_unused_result__)) __attribute__((__alloc_size__ (2)));
+
+long *
+slurp (long *buffer, unsigned long file_size)
+{
+  unsigned long cc;
+  if (!__builtin_add_overflow (file_size - file_size % sizeof (long),
+			       2 * sizeof (long), &cc))
+    buffer = realloc (buffer, cc);
+  return buffer;
+}
+
+long *
+slurp1 (long *buffer, unsigned long file_size)
+{
+  return realloc (buffer, file_size - file_size % sizeof (long));
+}
+
+long *
+slurp2 (long *buffer, unsigned long file_size)
+{
+  return realloc (buffer, (file_size / sizeof (long)) * sizeof (long));
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-10 12:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-10 12:29 [gcc r14-1685] testsuite: Add more allocation size tests for conjured svalues [PR110014] Tim Lange

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).